mirror of
https://github.com/zadam/trilium.git
synced 2025-01-15 19:51:57 +08:00
note cache fixes, #1805
This commit is contained in:
parent
e055d4e15e
commit
da741b522e
4 changed files with 16 additions and 6 deletions
|
@ -31,7 +31,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {
|
|||
for (const attr of note.ownedAttributes) {
|
||||
collectedAttributeIds.add(attr.attributeId);
|
||||
|
||||
if (attr.type === 'relation' && attr.name === 'template') {
|
||||
if (attr.type === 'relation' && attr.name === 'template' && attr.targetNote) {
|
||||
collectEntityIds(attr.targetNote);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,11 +234,19 @@ class Note {
|
|||
this.ancestorCache = null;
|
||||
}
|
||||
|
||||
invalidateSubtreeCaches() {
|
||||
invalidateSubtreeCaches(path = []) {
|
||||
if (path.includes(this.noteId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.invalidateThisCache();
|
||||
|
||||
if (this.children.length || this.targetRelations.length) {
|
||||
path = [...path, this.noteId];
|
||||
}
|
||||
|
||||
for (const childNote of this.children) {
|
||||
childNote.invalidateSubtreeCaches();
|
||||
childNote.invalidateSubtreeCaches(path);
|
||||
}
|
||||
|
||||
for (const targetRelation of this.targetRelations) {
|
||||
|
@ -246,7 +254,7 @@ class Note {
|
|||
const note = targetRelation.note;
|
||||
|
||||
if (note) {
|
||||
note.invalidateSubtreeCaches();
|
||||
note.invalidateSubtreeCaches(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,8 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
|
|||
// first invalidate and only then remove the attribute (otherwise invalidation wouldn't be complete)
|
||||
if (attr.isAffectingSubtree || note.isTemplate) {
|
||||
note.invalidateSubtreeCaches();
|
||||
} else {
|
||||
note.invalidateThisCache();
|
||||
}
|
||||
|
||||
note.ownedAttributes = note.ownedAttributes.filter(attr => attr.attributeId !== attributeId);
|
||||
|
@ -137,7 +139,7 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
|
|||
note.invalidateSubtreeFlatText();
|
||||
}
|
||||
else {
|
||||
note.flatTextCache = null;
|
||||
note.invalidateThisCache();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -18,7 +18,7 @@ class RelationWhereExp extends Expression {
|
|||
for (const attr of noteCache.findAttributes('relation', this.relationName)) {
|
||||
const note = attr.note;
|
||||
|
||||
if (inputNoteSet.hasNoteId(note.noteId)) {
|
||||
if (inputNoteSet.hasNoteId(note.noteId) && attr.targetNote) {
|
||||
const subInputNoteSet = new NoteSet([attr.targetNote]);
|
||||
const subResNoteSet = this.subExpression.execute(subInputNoteSet, executionContext);
|
||||
|
||||
|
|
Loading…
Reference in a new issue