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