mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
invalidate attribute cache on branch create/update, fixes #3994
This commit is contained in:
parent
d9359c7c55
commit
0c4492bcd0
@ -69,25 +69,6 @@ function reload() {
|
|||||||
require('../services/ws').reloadFrontend();
|
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}) => {
|
eventService.subscribeBeccaLoader([eventService.ENTITY_CHANGE_SYNCED], ({entityName, entityRow}) => {
|
||||||
if (!becca.loaded) {
|
if (!becca.loaded) {
|
||||||
return;
|
return;
|
||||||
@ -119,6 +100,25 @@ eventService.subscribeBeccaLoader(eventService.ENTITY_CHANGED, ({entityName, en
|
|||||||
postProcessEntityUpdate(entityName, entity);
|
postProcessEntityUpdate(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}) => {
|
eventService.subscribeBeccaLoader([eventService.ENTITY_DELETED, eventService.ENTITY_DELETE_SYNCED], ({entityName, entityId}) => {
|
||||||
if (!becca.loaded) {
|
if (!becca.loaded) {
|
||||||
return;
|
return;
|
||||||
@ -156,6 +156,7 @@ function branchDeleted(branchId) {
|
|||||||
.filter(parentBranch => parentBranch.branchId !== branch.branchId);
|
.filter(parentBranch => parentBranch.branchId !== branch.branchId);
|
||||||
|
|
||||||
if (childNote.parents.length > 0) {
|
if (childNote.parents.length > 0) {
|
||||||
|
// subtree notes might lose some inherited attributes
|
||||||
childNote.invalidateSubTree();
|
childNote.invalidateSubTree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,6 +186,10 @@ function branchUpdated(branchRow) {
|
|||||||
if (childNote) {
|
if (childNote) {
|
||||||
childNote.flatTextCache = null;
|
childNote.flatTextCache = null;
|
||||||
childNote.sortParents();
|
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];
|
const parentNote = becca.notes[branchRow.parentNoteId];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user