Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): drop cached attribute lists when froca is rebuilt

Elian Doranc1086f6d68c0
diff --git a/apps/client/src/services/froca.spec.ts b/apps/client/src/services/froca.spec.ts
index 3d64ac14d6..237b877a83 100644
--- a/apps/client/src/services/froca.spec.ts
+++ b/apps/client/src/services/froca.spec.ts
@@ -4,6 +4,7 @@ import appContext from "../components/app_context.js";
import FNote from "../entities/fnote.js";
import { buildNote } from "../test/easy-froca";
import froca from "./froca";
+import noteAttributeCache from "./note_attribute_cache.js";
import server from "./server.js";
// `logError` / `logInfo` are window globals referenced by froca; ensure they exist.
@@ -72,6 +73,18 @@ describe("reloadAll", () => {
expect(calls).toEqual([ "loadInitialTree", "reloadNotes" ]);
});
+
+ it("drops the attribute lists cached from the previous objects", async () => {
+ const note = buildNote({ title: "Cached", "#color": "red" });
+ expect(note.getAttributes()).toHaveLength(1);
+ expect(noteAttributeCache.attributes[note.noteId]).toHaveLength(1);
+ vi.spyOn(froca, "loadInitialTree").mockResolvedValue(undefined);
+ vi.spyOn(froca, "reloadNotes").mockResolvedValue(undefined);
+
+ await froca.reloadAll();
+
+ expect(note.noteId in noteAttributeCache.attributes).toBe(false);
+ });
});
describe("loadSubTree", () => {
diff --git a/apps/client/src/services/froca.ts b/apps/client/src/services/froca.ts
index 40d24f7a59..52f94e8fa4 100644
--- a/apps/client/src/services/froca.ts
+++ b/apps/client/src/services/froca.ts
@@ -10,6 +10,7 @@ import FBranch, { type FBranchRow } from "../entities/fbranch.js";
import FNote, { type FNoteRow } from "../entities/fnote.js";
import type { Bundle } from "./bundle.js";
import type { Froca, FrocaSource, NoteMapFilters, SavedAttachment, SubtreeResponse } from "./froca-interface.js";
+import noteAttributeCache from "./note_attribute_cache.js";
import server from "./server.js";
import { isPreAuthScreen, reuseAcrossHotReloads } from "./utils.js";
@@ -73,6 +74,7 @@ class FrocaImpl implements Froca {
await this.loadInitialTree();
await this.reloadNotes(allNoteIds);
+ noteAttributeCache.invalidate();
}
#clear() {