jellyfin-web/dashboard-ui/scripts/localsync.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-08-12 14:39:02 -07:00
(function () {
2015-09-10 11:28:22 -07:00
var syncPromise;
2015-08-12 14:39:02 -07:00
window.LocalSync = {
isSupported: function () {
2015-09-10 11:28:22 -07:00
return AppInfo.isNativeApp;
2015-08-12 14:39:02 -07:00
},
2015-09-21 18:05:33 -07:00
sync: function (options) {
2015-08-12 14:39:02 -07:00
2015-09-21 18:05:33 -07:00
if (syncPromise) {
return syncPromise.promise();
}
var deferred = DeferredBuilder.Deferred();
require(['multiserversync'], function () {
2015-09-10 11:28:22 -07:00
2015-09-22 09:06:27 -07:00
options = options || {};
if ($.browser.safari) {
options.enableBackgroundTransfer = true;
}
2015-09-21 18:05:33 -07:00
syncPromise = new MediaBrowser.MultiServerSync(ConnectionManager).sync(options).done(function () {
2015-09-10 11:28:22 -07:00
2015-09-21 18:05:33 -07:00
syncPromise = null;
deferred.resolve();
2015-09-10 11:28:22 -07:00
2015-09-21 18:05:33 -07:00
}).fail(function () {
2015-09-10 11:28:22 -07:00
2015-09-21 18:05:33 -07:00
syncPromise = null;
2015-09-10 11:28:22 -07:00
});
2015-09-21 18:05:33 -07:00
});
return deferred.promise();
2015-08-12 14:39:02 -07:00
},
getSyncStatus: function () {
2015-09-10 11:28:22 -07:00
if (syncPromise != null) {
return 'Syncing';
}
2015-08-12 14:39:02 -07:00
return 'Idle';
}
};
})();