Handle case where currently selected note is deleted by a remote sync
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user