clear auth hash depending on version

This commit is contained in:
Mo Bitar
2017-03-09 18:01:57 -06:00
parent 2a8bc1a0b4
commit 23611c31ae
4 changed files with 47 additions and 18 deletions

View File

@@ -172,7 +172,7 @@ class SyncManager {
params.sync_token = this.syncToken;
params.cursor_token = this.cursorToken;
this.httpManager.postAbsolute(this.syncURL, params, function(response){
var onSyncSuccess = function(response) {
this.modelManager.clearDirtyItems(subItems);
this.syncStatus.error = null;
@@ -209,19 +209,33 @@ class SyncManager {
} else {
this.callQueuedCallbacksAndCurrent(callback, response);
}
}.bind(this);
}.bind(this), function(response){
console.log("Sync error: ", response);
var error = response ? response.error : {message: "Could not connect to server."};
try {
this.httpManager.postAbsolute(this.syncURL, params, function(response){
this.syncStatus.syncOpInProgress = false;
this.syncStatus.error = error;
this.writeItemsToLocalStorage(allDirtyItems, false, null);
try {
onSyncSuccess(response);
} catch(e) {
console.log("Caught sync success exception:", e);
}
this.$rootScope.$broadcast("sync:error", error);
}.bind(this), function(response){
console.log("Sync error: ", response);
var error = response ? response.error : {message: "Could not connect to server."};
this.callQueuedCallbacksAndCurrent(callback, {error: "Sync error"});
}.bind(this));
this.syncStatus.syncOpInProgress = false;
this.syncStatus.error = error;
this.writeItemsToLocalStorage(allDirtyItems, false, null);
this.$rootScope.$broadcast("sync:error", error);
this.callQueuedCallbacksAndCurrent(callback, {error: "Sync error"});
}.bind(this));
}
catch(e) {
console.log("Sync exception caught:", e);
}
}
handleUnsavedItemsResponse(unsaved) {