Handle case where currently selected note is deleted by a remote sync

This commit is contained in:
Mo Bitar
2018-05-16 11:39:29 -05:00
parent ac73904d32
commit 53f75c7fe2
4 changed files with 38 additions and 7 deletions

View File

@@ -40,6 +40,26 @@ angular.module('app')
this.loadTagsString();
}.bind(this));
modelManager.addItemSyncObserver("component-manager", "Note", (allItems, validItems, deletedItems, source) => {
if(!this.note) { return; }
if(!ModelManager.isMappingSourceRetrieved(source)) {return;}
var matchingNote = allItems.find((item) => {
return item.uuid == this.note.uuid;
});
if(!matchingNote) {
return;
}
if(matchingNote.deleted) {
$rootScope.notifyDelete();
} else {
// Update tags
this.loadTagsString();
}
});
this.noteDidChange = function(note, oldNote) {
this.setNote(note, oldNote);
this.reloadComponentContext();