Sync integrity checking

This commit is contained in:
Mo Bitar
2019-02-05 13:57:07 -06:00
parent a9e52a2463
commit 3e39ba5239
5 changed files with 27 additions and 12 deletions

View File

@@ -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)

View File

@@ -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();

View File

@@ -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

6
package-lock.json generated
View File

@@ -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": {

View File

@@ -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"
}
}