Fix modelManager sync observer now being syncronous

This commit is contained in:
Mo Bitar
2019-06-04 13:36:56 -05:00
parent 02fe9dd6b0
commit 62b091ef5e
4 changed files with 20 additions and 19 deletions

View File

@@ -30,28 +30,30 @@ angular.module('app')
|| syncEvent == "local-data-incremental-load") {
this.tags = modelManager.tags;
this.smartTags = modelManager.getSmartTags();
if(this.noteCountsNeedReload) {
this.noteCountsNeedReload = false;
this.reloadNoteCounts();
}
}
});
modelManager.addItemSyncObserver("note-list", "*", (allItems, validItems, deletedItems, source, sourceKey) => {
// recompute note counts
let tags = [];
if(this.tags) {
tags = tags.concat(this.tags);
}
if(this.smartTags) {
tags = tags.concat(this.smartTags);
}
modelManager.addItemSyncObserver("tags-list", "*", (allItems, validItems, deletedItems, source, sourceKey) => {
this.noteCountsNeedReload = true;
});
for(let tag of tags) {
var validNotes = SNNote.filterDummyNotes(tag.notes).filter(function(note){
this.reloadNoteCounts = function() {
let allTags = [];
if(this.tags) { allTags = allTags.concat(this.tags);}
if(this.smartTags) { allTags = allTags.concat(this.smartTags);}
for(let tag of allTags) {
var validNotes = SNNote.filterDummyNotes(tag.notes).filter((note) => {
return !note.archived && !note.content.trashed;
});
tag.cachedNoteCount = validNotes.length;
}
});
}
this.panelController = {};

View File

@@ -3,8 +3,7 @@
%lock-screen{"ng-if" => "needsUnlock", "on-success" => "onSuccessfulUnlock"}
.app#app{"ng-if" => "!needsUnlock", "ng-class" => "appClass"}
%tags-section{"save" => "tagsSave", "add-new" => "tagsAddNew", "selection-made" => "tagsSelectionMade",
"tags" => "tags", "remove-tag" => "removeTag"}
%tags-section{"save" => "tagsSave", "add-new" => "tagsAddNew", "selection-made" => "tagsSelectionMade", "remove-tag" => "removeTag"}
%notes-section{"add-new" => "notesAddNew", "selection-made" => "notesSelectionMade", "tag" => "selectedTag"}
%editor-section{"note" => "selectedNote", "remove" => "deleteNote", "update-tags" => "updateTagsForNote"}