Fix client updated at, message when importing

This commit is contained in:
Mo Bitar
2018-06-08 10:12:04 -05:00
parent 0fd9a79559
commit be7a4b7b9f
5 changed files with 20 additions and 7 deletions

View File

@@ -246,9 +246,9 @@ class AccountMenu {
var onDataReady = function(errorCount) {
var items = modelManager.mapResponseItemsToLocalModels(data.items, ModelManager.MappingSourceFileImport);
items.forEach(function(item){
item.setDirty(true);
item.setDirty(true, true);
item.deleted = false;
item.markAllReferencesDirty();
item.markAllReferencesDirty(true);
// We don't want to activate any components during import process in case of exceptions
// breaking up the import proccess

View File

@@ -87,6 +87,9 @@ class Item {
if(dirty && !dontUpdateClientDate) {
// Set the client modified date to now if marking the item as dirty
this.client_updated_at = new Date();
} else if(!this.hasRawClientUpdatedAtValue()) {
// copy updated_at
this.client_updated_at = new Date(this.updated_at);
}
if(dirty) {
@@ -94,9 +97,9 @@ class Item {
}
}
markAllReferencesDirty() {
markAllReferencesDirty(dontUpdateClientDate) {
this.allReferencedObjects().forEach(function(reference){
reference.setDirty(true);
reference.setDirty(true, dontUpdateClientDate);
})
}
@@ -222,6 +225,10 @@ class Item {
return this.getAppDataItem("locked");
}
hasRawClientUpdatedAtValue() {
return this.getAppDataItem("client_updated_at") != null;
}
get client_updated_at() {
if(!this._client_updated_at) {
var saved = this.getAppDataItem("client_updated_at");

View File

@@ -411,7 +411,7 @@ class SyncManager {
) {
this.$rootScope.$broadcast("major-data-change");
}
this.callQueuedCallbacksAndCurrent(callback, response);
this.$rootScope.$broadcast("sync:completed", {retrievedItems: this.allRetreivedItems, savedItems: this.allSavedItems});