1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/localsync.js

45 lines
1 KiB
JavaScript
Raw Normal View History

2016-08-16 14:54:08 -04:00
define(['appSettings', 'connectionManager'], function (appSettings, connectionManager) {
2016-10-23 01:11:46 -04:00
'use strict';
2015-08-12 17:39:02 -04:00
2015-09-10 14:28:22 -04:00
var syncPromise;
2016-08-19 18:56:32 -04:00
return {
2015-08-12 17:39:02 -04:00
2015-09-21 21:05:33 -04:00
sync: function (options) {
2015-08-12 17:39:02 -04:00
2015-09-21 21:05:33 -04:00
if (syncPromise) {
return syncPromise.promise();
}
2015-12-14 10:43:03 -05:00
return new Promise(function (resolve, reject) {
2015-09-21 21:05:33 -04:00
2016-08-16 14:54:08 -04:00
require(['multiserversync'], function (MultiServerSync) {
2015-09-10 14:28:22 -04:00
2015-12-14 10:43:03 -05:00
options = options || {};
2015-09-22 12:06:27 -04:00
2016-03-01 01:02:03 -05:00
options.cameraUploadServers = appSettings.cameraUploadServers();
2015-09-26 10:51:26 -04:00
2016-08-16 14:54:08 -04:00
syncPromise = new MultiServerSync(connectionManager).sync(options).then(function () {
2015-09-10 14:28:22 -04:00
2015-12-14 10:43:03 -05:00
syncPromise = null;
resolve();
2015-09-10 14:28:22 -04:00
2015-12-14 10:43:03 -05:00
}, function () {
2015-09-10 14:28:22 -04:00
2015-12-14 10:43:03 -05:00
syncPromise = null;
});
2015-09-10 14:28:22 -04:00
});
2015-09-21 21:05:33 -04:00
2015-12-14 10:43:03 -05:00
});
2015-08-12 17:39:02 -04:00
},
getSyncStatus: function () {
2015-09-10 14:28:22 -04:00
if (syncPromise != null) {
return 'Syncing';
}
2015-08-12 17:39:02 -04:00
return 'Idle';
}
};
2016-03-01 01:02:03 -05:00
});