Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

Commit

Permalink
update localsync
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePulverenti committed Oct 9, 2017
1 parent 0981bd1 commit f72e12e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 10 additions & 6 deletions sync/localsync.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
define(['appSettings', 'connectionManager'], function (appSettings, connectionManager) {
'use strict';

var syncPromise;
var isSyncing;

return {

sync: function (options) {

if (syncPromise) {
return syncPromise;
console.log('localSync.sync starting...');

if (isSyncing) {
return Promise.resolve();
}

isSyncing = true;

return new Promise(function (resolve, reject) {

require(['multiserversync'], function (MultiServerSync) {
Expand All @@ -19,14 +23,14 @@

options.cameraUploadServers = appSettings.cameraUploadServers();

syncPromise = new MultiServerSync().sync(connectionManager, options).then(function () {
new MultiServerSync().sync(connectionManager, options).then(function () {

syncPromise = null;
isSyncing = null;
resolve();

}, function () {

syncPromise = null;
isSyncing = null;
reject();
});
});
Expand Down
2 changes: 2 additions & 0 deletions sync/multiserversync.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

MultiServerSync.prototype.sync = function (connectionManager, options) {

console.log('MultiServerSync.sync starting...');

return new Promise(function (resolve, reject) {

var servers = connectionManager.getSavedServers();
Expand Down

0 comments on commit f72e12e

Please sign in to comment.