diff --git a/app/assets/javascripts/app/controllers/footer.js b/app/assets/javascripts/app/controllers/footer.js index 0bb3add86..efee7069a 100644 --- a/app/assets/javascripts/app/controllers/footer.js +++ b/app/assets/javascripts/app/controllers/footer.js @@ -86,12 +86,21 @@ angular.module('app') } this.updateOfflineStatus(); - $rootScope.$on("initial-data-loaded", () => { - // If the user has no notes and is offline, show Account menu - if(this.offline && modelManager.noteCount() == 0) { - this.showAccountMenu = true; - } - }) + + syncManager.addEventHandler((syncEvent, data) => { + $timeout(() => { + if(syncEvent == "local-data-loaded") { + // If the user has no notes and is offline, show Account menu + if(this.offline && modelManager.noteCount() == 0) { + this.showAccountMenu = true; + } + } else if(syncEvent == "enter-out-of-sync") { + this.outOfSync = true; + } else if(syncEvent == "exit-out-of-sync") { + this.outOfSync = false; + } + }) + }); this.findErrors = function() { this.error = syncManager.syncStatus.error; @@ -121,7 +130,8 @@ angular.module('app') this.refreshData = function() { this.isRefreshing = true; - syncManager.sync({force: true}).then((response) => { + // Enable integrity checking for this force request + syncManager.sync({force: true, performIntegrityCheck: true}).then((response) => { $timeout(function(){ this.isRefreshing = false; }.bind(this), 200) diff --git a/app/assets/javascripts/app/controllers/home.js b/app/assets/javascripts/app/controllers/home.js index 4905bab32..503baaf76 100644 --- a/app/assets/javascripts/app/controllers/home.js +++ b/app/assets/javascripts/app/controllers/home.js @@ -91,7 +91,8 @@ angular.module('app') syncManager.loadLocalItems().then(() => { $timeout(() => { $rootScope.$broadcast("initial-data-loaded"); // This needs to be processed first before sync is called so that singletonManager observers function properly. - syncManager.sync(); + // Perform integrity check on first sync + syncManager.sync({performIntegrityCheck: true}); // refresh every 30s setInterval(function () { syncManager.sync(); diff --git a/app/assets/templates/footer.html.haml b/app/assets/templates/footer.html.haml index f8d3ce768..bcc864787 100644 --- a/app/assets/templates/footer.html.haml +++ b/app/assets/templates/footer.html.haml @@ -37,6 +37,10 @@ .sk-app-bar-item.no-pointer{"ng-if" => "ctrl.lastSyncDate && !ctrl.isRefreshing"} .sk-label.subtle Last refreshed {{ctrl.lastSyncDate | appDateTime}} + + .sk-app-bar-item{"ng-if" => "ctrl.outOfSync && !ctrl.isRefreshing"} + .sk-label.warning Potentially Out of Sync + .sk-app-bar-item{"ng-if" => "ctrl.lastSyncDate && ctrl.isRefreshing"} .sk-spinner.small diff --git a/package-lock.json b/package-lock.json index aa610e300..decec2faf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4830,9 +4830,9 @@ "dev": true }, "standard-file-js": { - "version": "0.3.42", - "resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.42.tgz", - "integrity": "sha512-FCBOnW7iJ8GjIcIba5etBAmSNiPZ8PGhrsF86QgqdutKZ0lyALpSgOoWSUHmFwZNXhEB47znyqybqZ8ReV6LZg==", + "version": "0.3.43", + "resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.43.tgz", + "integrity": "sha512-Adwy9ims9YnX++mhX5fhY4+X0slCPgeUF54IFmH4MOZHcJkwSHKBLA426QxzKFWs3F3IKD2fsiKnYf2uXEuepw==", "dev": true }, "statuses": { diff --git a/package.json b/package.json index d32722ae0..bb3bf5d51 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "serve-static": "^1.13.2", "sn-models": "0.1.13", "sn-stylekit": "2.0.13", - "standard-file-js": "0.3.42", + "standard-file-js": "0.3.43", "grunt-shell": "^2.1.0" } }