Skip to content

Build your personal knowledge base with Trilium Notes

fix modifying index in note cache when deleting attribute, closes #1706

zadam14ced949a921
diff --git a/src/services/note_cache/note_cache_loader.js b/src/services/note_cache/note_cache_loader.js
index 0d53ea0200..336deee5ff 100644
--- a/src/services/note_cache/note_cache_loader.js
+++ b/src/services/note_cache/note_cache_loader.js
@@ -120,7 +120,11 @@ eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED
delete noteCache.attributes[attributeId];
if (attr) {
- delete noteCache.attributeIndex[`${attr.type}-${attr.name.toLowerCase()}`];
+ const key = `${attr.type}-${attr.name.toLowerCase()}`;
+
+ if (key in noteCache.attributeIndex) {
+ noteCache.attributeIndex[key] = noteCache.attributeIndex[key].filter(attr => attr.attributeId !== attributeId);
+ }
}
}
else if (attributeId in noteCache.attributes) {