Don't clear item as dirty if it was marked dirty after a sync began
This commit is contained in:
@@ -64,6 +64,16 @@ class Item {
|
|||||||
setDirty(dirty) {
|
setDirty(dirty) {
|
||||||
this.dirty = dirty;
|
this.dirty = dirty;
|
||||||
|
|
||||||
|
// Allows the syncManager to check if an item has been marked dirty after a sync has been started
|
||||||
|
// This prevents it from clearing it as a dirty item after sync completion, if someone else has marked it dirty
|
||||||
|
// again after an ongoing sync.
|
||||||
|
if(!this.dirtyCount) { this.dirtyCount = 0; }
|
||||||
|
if(dirty) {
|
||||||
|
this.dirtyCount++;
|
||||||
|
} else {
|
||||||
|
this.dirtyCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(dirty) {
|
if(dirty) {
|
||||||
this.notifyObserversOfChange();
|
this.notifyObserversOfChange();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,6 +270,12 @@ class SyncManager {
|
|||||||
return itemParams.paramsForSync();
|
return itemParams.paramsForSync();
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
for(var item of subItems) {
|
||||||
|
// Reset dirty counter to 0, since we're about to sync it.
|
||||||
|
// This means anyone marking the item as dirty after this will cause it so sync again and not be cleared on sync completion.
|
||||||
|
item.dirtyCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
params.sync_token = this.syncToken;
|
params.sync_token = this.syncToken;
|
||||||
params.cursor_token = this.cursorToken;
|
params.cursor_token = this.cursorToken;
|
||||||
|
|
||||||
@@ -278,7 +284,15 @@ class SyncManager {
|
|||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
var onSyncSuccess = function(response) {
|
var onSyncSuccess = function(response) {
|
||||||
this.modelManager.clearDirtyItems(subItems);
|
// Check to make sure any subItem hasn't been marked as dirty again while a sync was ongoing
|
||||||
|
var itemsToClearAsDirty = [];
|
||||||
|
for(var item of subItems) {
|
||||||
|
if(item.dirtyCount == 0) {
|
||||||
|
// Safe to clear as dirty
|
||||||
|
itemsToClearAsDirty.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.modelManager.clearDirtyItems(itemsToClearAsDirty);
|
||||||
this.syncStatus.error = null;
|
this.syncStatus.error = null;
|
||||||
|
|
||||||
this.$rootScope.$broadcast("sync:updated_token", this.syncToken);
|
this.$rootScope.$broadcast("sync:updated_token", this.syncToken);
|
||||||
|
|||||||
@@ -173,6 +173,8 @@
|
|||||||
%input{"type" => "file", "style" => "display: none;", "file-change" => "->", "handler" => "importFileSelected(files)"}
|
%input{"type" => "file", "style" => "display: none;", "file-change" => "->", "handler" => "importFileSelected(files)"}
|
||||||
.label Import From Backup
|
.label Import From Backup
|
||||||
|
|
||||||
|
%span{"ng-if" => "isDesktopApplication()"} Backups are automatically created on desktop and can be managed via the "Backups" top-level menu.
|
||||||
|
|
||||||
%div{"ng-if" => "importData.requestPassword"}
|
%div{"ng-if" => "importData.requestPassword"}
|
||||||
%form.panel-form.stretch{"ng-submit" => "submitImportPassword()"}
|
%form.panel-form.stretch{"ng-submit" => "submitImportPassword()"}
|
||||||
%p Enter the account password associated with the import file.
|
%p Enter the account password associated with the import file.
|
||||||
|
|||||||
Reference in New Issue
Block a user