2016-02-29 23:02:03 -07:00
|
|
|
|
define(['appSettings'], function (appSettings) {
|
2015-08-12 14:39:02 -07:00
|
|
|
|
|
2015-09-10 11:28:22 -07:00
|
|
|
|
var syncPromise;
|
|
|
|
|
|
2015-08-12 14:39:02 -07:00
|
|
|
|
window.LocalSync = {
|
|
|
|
|
|
|
|
|
|
isSupported: function () {
|
2015-10-05 19:50:20 -07:00
|
|
|
|
return AppInfo.isNativeApp && Dashboard.capabilities().SupportsSync;
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
return new Promise(function (resolve, reject) {
|
2015-09-21 18:05:33 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
require(['multiserversync'], function () {
|
2015-09-10 11:28:22 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
options = options || {};
|
2015-09-22 09:06:27 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
LocalSync.normalizeSyncOptions(options);
|
2015-09-22 09:06:27 -07:00
|
|
|
|
|
2016-02-29 23:02:03 -07:00
|
|
|
|
options.cameraUploadServers = appSettings.cameraUploadServers();
|
2015-09-26 07:51:26 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
syncPromise = new MediaBrowser.MultiServerSync(ConnectionManager).sync(options).then(function () {
|
2015-09-10 11:28:22 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
syncPromise = null;
|
|
|
|
|
resolve();
|
2015-09-10 11:28:22 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}, function () {
|
2015-09-10 11:28:22 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
syncPromise = null;
|
|
|
|
|
});
|
2015-09-10 11:28:22 -07:00
|
|
|
|
});
|
2015-09-21 18:05:33 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
});
|
2015-08-12 14:39:02 -07:00
|
|
|
|
},
|
|
|
|
|
|
2015-09-28 20:35:50 -07:00
|
|
|
|
normalizeSyncOptions: function (options) {
|
2016-02-29 23:02:03 -07:00
|
|
|
|
|
2015-09-28 20:35:50 -07:00
|
|
|
|
},
|
|
|
|
|
|
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';
|
|
|
|
|
}
|
|
|
|
|
};
|
2016-02-29 23:02:03 -07:00
|
|
|
|
|
|
|
|
|
});
|