Transition from item.setDirty to modelManager.setItemDirty

This commit is contained in:
Mo Bitar
2019-05-22 18:17:25 -05:00
parent 10022ba87b
commit af85d7c384
12 changed files with 36 additions and 40 deletions

View File

@@ -76,12 +76,12 @@ class ActionsManager {
if(merge) {
var items = this.modelManager.mapResponseItemsToLocalModels([item], SFModelManager.MappingSourceRemoteActionRetrieved);
for(var mappedItem of items) {
mappedItem.setDirty(true);
this.modelManager.setItemDirty(mappedItem, true);
}
this.syncManager.sync();
customCallback({item: item});
} else {
item = this.modelManager.createItem(item, true /* Dont notify observers */);
item = this.modelManager.createItem(item);
customCallback({item: item});
}
return true;

View File

@@ -145,7 +145,7 @@ class AuthManager extends SFAuthManager {
// Safe to create. Create and return object.
var prefs = new SFItem({content_type: prefsContentType});
this.modelManager.addItem(prefs);
prefs.setDirty(true);
this.modelManager.setItemDirty(prefs, true);
this.$rootScope.sync();
valueCallback(prefs);
});
@@ -157,7 +157,7 @@ class AuthManager extends SFAuthManager {
syncUserPreferences() {
if(this.userPreferences) {
this.userPreferences.setDirty(true);
this.modelManager.setItemDirty(this.userPreferences, true);
this.$rootScope.sync();
}
}

View File

@@ -112,7 +112,8 @@ class DesktopManager {
this.modelManager.notifySyncObserversOfModels([component], SFModelManager.MappingSourceDesktopInstalled);
component.setAppDataItem("installError", null);
}
component.setDirty(true);
this.modelManager.setItemDirty(component, true);
this.syncManager.sync();
this.timeout(() => {

View File

@@ -38,8 +38,8 @@ class MigrationManager extends SFMigrationManager {
}
})
component.setAppDataItem("data", editor.data);
component.setDirty(true);
this.modelManager.addItem(component);
this.modelManager.setItemDirty(component, true);
}
}
@@ -76,7 +76,7 @@ class MigrationManager extends SFMigrationManager {
if(clientData) {
note.setDomainDataItem(component.uuid, clientData, ComponentManager.ClientDataDomain);
note.setDomainDataItem(component.hosted_url, null, ComponentManager.ClientDataDomain);
note.setDirty(true);
this.modelManager.setItemDirty(note, true);
hasChanges = true;
}
}
@@ -126,14 +126,14 @@ class MigrationManager extends SFMigrationManager {
let tag = this.modelManager.findItem(reference.uuid);
if(tag && !tag.hasRelationshipWithItem(note)) {
tag.addItemAsRelationship(note);
tag.setDirty(true);
this.modelManager.setItemDirty(tag, true);
dirtyCount++;
}
}
if(newReferences.length != references.length) {
note.content.references = newReferences;
note.setDirty(true);
this.modelManager.setItemDirty(note, true);
dirtyCount++;
}
}

View File

@@ -49,8 +49,8 @@ class ModelManager extends SFModelManager {
var tag = _.find(this.tags, {title: title})
if(!tag) {
tag = this.createItem({content_type: "Tag", content: {title: title}});
tag.setDirty(true);
this.addItem(tag);
this.setItemDirty(tag, true);
}
return tag;
}

View File

@@ -49,7 +49,7 @@ class NativeExtManager {
}
if(needsSync) {
resolvedSingleton.setDirty(true);
this.modelManager.setItemDirty(resolvedSingleton, true);
this.syncManager.sync();
}
}, (valueCallback) => {
@@ -93,7 +93,7 @@ class NativeExtManager {
var component = this.modelManager.createItem(item);
this.modelManager.addItem(component);
component.setDirty(true);
this.modelManager.setItemDirty(component, true);
this.syncManager.sync();
this.systemExtensions.push(component.uuid);
@@ -125,7 +125,7 @@ class NativeExtManager {
}
if(needsSync) {
resolvedSingleton.setDirty(true);
this.modelManager.setItemDirty(resolvedSingleton, true);
this.syncManager.sync();
}
}, (valueCallback) => {
@@ -171,7 +171,7 @@ class NativeExtManager {
var component = this.modelManager.createItem(item);
this.modelManager.addItem(component);
component.setDirty(true);
this.modelManager.setItemDirty(component, true);
this.syncManager.sync();
this.systemExtensions.push(component.uuid);