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"}

6
package-lock.json generated
View File

@@ -5724,9 +5724,9 @@
}
},
"snjs": {
"version": "0.2.6",
"resolved": "https://registry.npmjs.org/snjs/-/snjs-0.2.6.tgz",
"integrity": "sha512-nBWwzNcOKtCj6Z0f0buD/vswd3agU+sI2KHWQuUn1tuhNoGdzh20DgjcmxEEmW7QiiEkvZHDL/TC8N47tx66SQ==",
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/snjs/-/snjs-0.2.7.tgz",
"integrity": "sha512-MPegTzgrQY5xh24jBsAQKqxiCpLDDtgelcrv4G1Xz6yZqH2H2WrUTr7YSE1QCPbKHMXvuX7kn/cTDchyhEdESQ==",
"dev": true
},
"source-map": {

View File

@@ -39,7 +39,7 @@
"mocha": "^5.2.0",
"serve-static": "^1.13.2",
"sn-stylekit": "2.0.15",
"snjs": "0.2.6",
"snjs": "0.2.7",
"standard-file-js": "0.3.63"
}
}