From 5be3c5eab37d846c981cb5995abaddb005a120f5 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Wed, 16 May 2018 11:50:00 -0500 Subject: [PATCH] Handle case where offline item id alternates but does not remove old object from active editor session --- .../javascripts/app/controllers/editor.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/app/controllers/editor.js b/app/assets/javascripts/app/controllers/editor.js index d2f8766b8..5fcb72b79 100644 --- a/app/assets/javascripts/app/controllers/editor.js +++ b/app/assets/javascripts/app/controllers/editor.js @@ -42,7 +42,18 @@ angular.module('app') modelManager.addItemSyncObserver("component-manager", "Note", (allItems, validItems, deletedItems, source) => { if(!this.note) { return; } - if(!ModelManager.isMappingSourceRetrieved(source)) {return;} + + // Before checking if isMappingSourceRetrieved, we check if this item was deleted via a local source, + // such as alternating uuids during sign in. Otherwise, we only want to make interface updates if it's a + // remote retrieved source. + if(this.note.deleted) { + $rootScope.notifyDelete(); + return; + } + + if(!ModelManager.isMappingSourceRetrieved(source)) { + return; + } var matchingNote = allItems.find((item) => { return item.uuid == this.note.uuid; @@ -52,12 +63,8 @@ angular.module('app') return; } - if(matchingNote.deleted) { - $rootScope.notifyDelete(); - } else { - // Update tags - this.loadTagsString(); - } + // Update tags + this.loadTagsString(); }); this.noteDidChange = function(note, oldNote) {