diff --git a/app/assets/javascripts/app/controllers/editor.js b/app/assets/javascripts/app/controllers/editor.js index f2cbaf85a..7595d4698 100644 --- a/app/assets/javascripts/app/controllers/editor.js +++ b/app/assets/javascripts/app/controllers/editor.js @@ -198,14 +198,14 @@ angular.module('app') if(editor) { if(this.note.getAppDataItem("prefersPlainEditor") == true) { this.note.setAppDataItem("prefersPlainEditor", false); - this.note.setDirty(true); + modelManager.setItemDirty(this.note, true); } this.associateComponentWithCurrentNote(editor); } else { // Note prefers plain editor if(!this.note.getAppDataItem("prefersPlainEditor")) { this.note.setAppDataItem("prefersPlainEditor", true); - this.note.setDirty(true); + modelManager.setItemDirty(this.note, true); } $timeout(() => { this.reloadFont(); @@ -249,7 +249,7 @@ angular.module('app') this.saveNote = function(note, callback, updateClientModified, dontUpdatePreviews) { // We don't want to update the client modified date if toggling lock for note. - note.setDirty(true, updateClientModified); + modelManager.setItemDirty(note, true, updateClientModified); if(!dontUpdatePreviews) { let limit = 80; @@ -688,20 +688,12 @@ angular.module('app') if(data.item.content_type == "Tag") { var tag = modelManager.findItem(data.item.uuid); this.addTag(tag); - - // Currently extensions are not notified of association until a full server sync completes. - // We need a better system for this, but for now, we'll manually notify observers - modelManager.notifySyncObserversOfModels([tag], SFModelManager.MappingSourceLocalSaved); } } else if(action === "deassociate-item") { var tag = modelManager.findItem(data.item.uuid); this.removeTag(tag); - - // Currently extensions are not notified of association until a full server sync completes. - // We need a better system for this, but for now, we'll manually notify observers - modelManager.notifySyncObserversOfModels([tag], SFModelManager.MappingSourceLocalSaved); } else if(action === "save-items" || action === "save-success" || action == "save-error") { @@ -785,7 +777,7 @@ angular.module('app') component.disassociatedItemIds.push(this.note.uuid); } - component.setDirty(true); + modelManager.setItemDirty(component, true); syncManager.sync(); } @@ -796,7 +788,7 @@ angular.module('app') component.associatedItemIds.push(this.note.uuid); } - component.setDirty(true); + modelManager.setItemDirty(component, true); syncManager.sync(); } diff --git a/app/assets/javascripts/app/controllers/home.js b/app/assets/javascripts/app/controllers/home.js index 49e37c873..ddcc2e665 100644 --- a/app/assets/javascripts/app/controllers/home.js +++ b/app/assets/javascripts/app/controllers/home.js @@ -172,9 +172,10 @@ angular.module('app') for(var tagToRemove of toRemove) { tagToRemove.removeItemAsRelationship(note); - tagToRemove.setDirty(true); } + modelManager.setItemsDirty(toRemove, true); + var tags = []; for(var tagString of stringTags) { var existingRelationship = _.find(note.tags, {title: tagString}); @@ -185,9 +186,10 @@ angular.module('app') for(var tag of tags) { tag.addItemAsRelationship(note); - tag.setDirty(true); } + modelManager.setItemsDirty(tags, true); + syncManager.sync(); } @@ -219,7 +221,8 @@ angular.module('app') $scope.removeTag(tag); return; } - tag.setDirty(true); + + modelManager.setItemDirty(tag, true); syncManager.sync().then(callback); modelManager.resortTag(tag); } @@ -247,7 +250,7 @@ angular.module('app') if(!$scope.selectedTag.isSmartTag()) { $scope.selectedTag.addItemAsRelationship(note); - $scope.selectedTag.setDirty(true); + modelManager.setItemDirty($scope.selectedTag, true); } } diff --git a/app/assets/javascripts/app/controllers/notes.js b/app/assets/javascripts/app/controllers/notes.js index 54fc9bff6..fec78bf90 100644 --- a/app/assets/javascripts/app/controllers/notes.js +++ b/app/assets/javascripts/app/controllers/notes.js @@ -371,7 +371,7 @@ angular.module('app') this.selectedNote = note; if(note.content.conflict_of) { note.content.conflict_of = null; // clear conflict - note.setDirty(true); + modelManager.setItemDirty(note, true); syncManager.sync(); } this.selectionMade()(note); diff --git a/app/assets/javascripts/app/controllers/tags.js b/app/assets/javascripts/app/controllers/tags.js index 57302abc6..b653a8d89 100644 --- a/app/assets/javascripts/app/controllers/tags.js +++ b/app/assets/javascripts/app/controllers/tags.js @@ -108,8 +108,8 @@ angular.module('app') } this.selectedTag = tag; if(tag.content.conflict_of) { - tag.content.conflict_of = null; // clear conflict - tag.setDirty(true); + tag.content.conflict_of = null; + modelManager.setItemDirty(tag, true); syncManager.sync(); } this.selectionMade()(tag); diff --git a/app/assets/javascripts/app/directives/views/editorMenu.js b/app/assets/javascripts/app/directives/views/editorMenu.js index 1232e65b7..5bcc100f4 100644 --- a/app/assets/javascripts/app/directives/views/editorMenu.js +++ b/app/assets/javascripts/app/directives/views/editorMenu.js @@ -10,7 +10,7 @@ class EditorMenu { }; } - controller($scope, componentManager, syncManager, $timeout) { + controller($scope, componentManager, syncManager, modelManager, $timeout) { 'ngInject'; $scope.formData = {}; @@ -27,7 +27,7 @@ class EditorMenu { if(component) { if(component.content.conflict_of) { component.content.conflict_of = null; // clear conflict if applicable - component.setDirty(true); + modelManager.setItemDirty(component, true); syncManager.sync(); } } @@ -52,11 +52,11 @@ class EditorMenu { var currentDefault = componentManager.componentsForArea("editor-editor").filter((e) => {return e.isDefaultEditor()})[0]; if(currentDefault) { currentDefault.setAppDataItem("defaultEditor", false); - currentDefault.setDirty(true); + modelManager.setItemDirty(currentDefault, true); } component.setAppDataItem("defaultEditor", true); - component.setDirty(true); + modelManager.setItemDirty(component, true); syncManager.sync(); $scope.defaultEditor = component; @@ -64,7 +64,7 @@ class EditorMenu { $scope.removeEditorDefault = function(component) { component.setAppDataItem("defaultEditor", false); - component.setDirty(true); + modelManager.setItemDirty(component, true); syncManager.sync(); $scope.defaultEditor = null; diff --git a/app/assets/javascripts/app/directives/views/revisionPreviewModal.js b/app/assets/javascripts/app/directives/views/revisionPreviewModal.js index 70891f354..e1844493e 100644 --- a/app/assets/javascripts/app/directives/views/revisionPreviewModal.js +++ b/app/assets/javascripts/app/directives/views/revisionPreviewModal.js @@ -78,7 +78,7 @@ class RevisionPreviewModal { modelManager.mapResponseItemsToLocalModels([item], SFModelManager.MappingSourceRemoteActionRetrieved); } - item.setDirty(true); + modelManager.setItemDirty(item, true); syncManager.sync(); $scope.dismiss(); diff --git a/app/assets/javascripts/app/services/actionsManager.js b/app/assets/javascripts/app/services/actionsManager.js index 1443d8b06..d3ca5636e 100644 --- a/app/assets/javascripts/app/services/actionsManager.js +++ b/app/assets/javascripts/app/services/actionsManager.js @@ -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; diff --git a/app/assets/javascripts/app/services/authManager.js b/app/assets/javascripts/app/services/authManager.js index ec54f1232..83fcabdf6 100644 --- a/app/assets/javascripts/app/services/authManager.js +++ b/app/assets/javascripts/app/services/authManager.js @@ -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(); } } diff --git a/app/assets/javascripts/app/services/desktopManager.js b/app/assets/javascripts/app/services/desktopManager.js index cb691e058..30c5957df 100644 --- a/app/assets/javascripts/app/services/desktopManager.js +++ b/app/assets/javascripts/app/services/desktopManager.js @@ -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(() => { diff --git a/app/assets/javascripts/app/services/migrationManager.js b/app/assets/javascripts/app/services/migrationManager.js index 2fd873b93..5bc659ade 100644 --- a/app/assets/javascripts/app/services/migrationManager.js +++ b/app/assets/javascripts/app/services/migrationManager.js @@ -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++; } } diff --git a/app/assets/javascripts/app/services/modelManager.js b/app/assets/javascripts/app/services/modelManager.js index 168f551d9..218704a3f 100644 --- a/app/assets/javascripts/app/services/modelManager.js +++ b/app/assets/javascripts/app/services/modelManager.js @@ -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; } diff --git a/app/assets/javascripts/app/services/nativeExtManager.js b/app/assets/javascripts/app/services/nativeExtManager.js index 9cc69d7a8..f648c5a83 100644 --- a/app/assets/javascripts/app/services/nativeExtManager.js +++ b/app/assets/javascripts/app/services/nativeExtManager.js @@ -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);