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
client/collections/board: fix an issue
Adorian Doraneb3cc57d3013
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsxindex acf9e748a9..071bc6a5df 100644--- a/apps/client/src/widgets/collections/board/index.spec.tsx+++ b/apps/client/src/widgets/collections/board/index.spec.tsx@@ -2337,7 +2337,8 @@ describe("Board column rename", () => {/*** A template's icon is what the picker and the pill show, and an icon is a label on the note* rather than part of the note row: the change is reported as an attribute changing, which is- * not what a reloaded note reads as. Only the notes the board offers are watched for it.+ * not what a reloaded note reads as. The label is not always `iconClass`, so any label on a+ * note the board offers sends it back for the list. Notes it offers nothing from are its own.*/it("reads the templates again when one it offers is given another icon", async () => {const reading = vi.mocked(getNoteTypeOptions);@@ -2377,6 +2378,14 @@ describe("Board column rename", () => {await flush();});expect(reading.mock.calls.length).toBe(before + 2);++ // A note with no icon of its own wears its workspace's, which is another label again.+ await act(async () => {+ await host.handleEvent("entitiesReloaded",+ { loadResults: attributeChanged("workspaceIconClass", "tmpl1") });+ await flush();+ });+ expect(reading.mock.calls.length).toBe(before + 3);} finally {reading.mockImplementation(stockAnswer ?? (async () => NOTE_TYPE_OPTIONS));}diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsxindex 0e731ab8d9..d84e1d9c69 100644--- a/apps/client/src/widgets/collections/board/index.tsx+++ b/apps/client/src/widgets/collections/board/index.tsx@@ -301,13 +301,13 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveCconst offered = new Set(availableTemplates.map((option) => option.options.templateNoteId).filter((noteId) => !!noteId));- // A note taking `#template` or losing it changes what a card can be made from, and so does- // the icon of one already offered. An icon is a label rather than part of the note row, so- // a change to one is reported as the attribute changing and not as the note reloading.+ // A note taking `#template` or losing it changes what a card can be made from. So does any+ // attribute of a note already offered: the icon the picker shows comes from `iconClass`,+ // from `workspaceIconClass` where there is none, and from a `#geoLocation` on a text note,+ // all of them labels rather than part of the note row a reload would report.const templated = loadResults.getAttributeRows().some((attribute) =>attribute.name === "template"- || (attribute.name === "iconClass" && !!attribute.noteId- && offered.has(attribute.noteId)));+ || (!!attribute.noteId && offered.has(attribute.noteId)));const renamed = availableTemplates.some((option) =>option.options.templateNoteId&& loadResults.isNoteReloaded(option.options.templateNoteId));