Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
invalidate attribute cache on branch create/update, fixes #3994
zadam0c4492bcd033
diff --git a/src/becca/becca_loader.js b/src/becca/becca_loader.jsindex 82dd09e426..dd8e990a4d 100644--- a/src/becca/becca_loader.js+++ b/src/becca/becca_loader.js@@ -69,25 +69,6 @@ function reload() {require('../services/ws').reloadFrontend();}-/**- * This gets run on entity being created or updated.- *- * @param entityName- * @param entityRow - can be a becca entity (change comes from this trilium instance) or just a row (from sync).- * Should be therefore treated as a row.- */-function postProcessEntityUpdate(entityName, entityRow) {- if (entityName === 'notes') {- noteUpdated(entityRow);- } else if (entityName === 'branches') {- branchUpdated(entityRow);- } else if (entityName === 'attributes') {- attributeUpdated(entityRow);- } else if (entityName === 'note_reordering') {- noteReorderingUpdated(entityRow);- }-}-eventService.subscribeBeccaLoader([eventService.ENTITY_CHANGE_SYNCED], ({entityName, entityRow}) => {if (!becca.loaded) {return;@@ -119,6 +100,25 @@ eventService.subscribeBeccaLoader(eventService.ENTITY_CHANGED, ({entityName, enpostProcessEntityUpdate(entityName, entity);});+/**+ * This gets run on entity being created or updated.+ *+ * @param entityName+ * @param entityRow - can be a becca entity (change comes from this trilium instance) or just a row (from sync).+ * Should be therefore treated as a row.+ */+function postProcessEntityUpdate(entityName, entityRow) {+ if (entityName === 'notes') {+ noteUpdated(entityRow);+ } else if (entityName === 'branches') {+ branchUpdated(entityRow);+ } else if (entityName === 'attributes') {+ attributeUpdated(entityRow);+ } else if (entityName === 'note_reordering') {+ noteReorderingUpdated(entityRow);+ }+}+eventService.subscribeBeccaLoader([eventService.ENTITY_DELETED, eventService.ENTITY_DELETE_SYNCED], ({entityName, entityId}) => {if (!becca.loaded) {return;@@ -156,6 +156,7 @@ function branchDeleted(branchId) {.filter(parentBranch => parentBranch.branchId !== branch.branchId);if (childNote.parents.length > 0) {+ // subtree notes might lose some inherited attributeschildNote.invalidateSubTree();}}@@ -185,6 +186,10 @@ function branchUpdated(branchRow) {if (childNote) {childNote.flatTextCache = null;childNote.sortParents();++ // notes in the subtree can get new inherited attributes+ // this is in theory needed upon branch creation, but there's no create event for sync changes+ childNote.invalidateSubTree();}const parentNote = becca.notes[branchRow.parentNoteId];