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
fix(client): edge case not handled when parent note overrides to false
Elian Doran26c25cd4cdbf
diff --git a/apps/client/src/services/attributes.spec.ts b/apps/client/src/services/attributes.spec.tsindex cd52cb6d5f..13be027650 100644--- a/apps/client/src/services/attributes.spec.ts+++ b/apps/client/src/services/attributes.spec.ts@@ -110,4 +110,42 @@ describe("Set boolean with inheritance", () => {await setBooleanWithInheritance(childNote, "foo", true);expect(server.remove).toHaveBeenCalledWith(`notes/${childNote.noteId}/attributes/${childNote.getLabel("foo")!.attributeId}`);});++ it("overrides boolean with inherited false", async () => {+ const parentNote = buildNote({+ title: "Parent note",+ "#foo(inheritable)": "false",+ "children": [+ {+ title: "Child note"+ }+ ]+ });+ const childNote = froca.getNoteFromCache(parentNote.children[0])!;+ expect(childNote.isLabelTruthy("foo")).toBe(false);+ await setBooleanWithInheritance(childNote, "foo", true);+ expect(server.put).toHaveBeenCalledWith(`notes/${childNote.noteId}/set-attribute`, {+ type: "label",+ name: "foo",+ value: "",+ isInheritable: false+ });+ });++ it("deletes override boolean with inherited false with already existing value", async () => {+ const parentNote = buildNote({+ title: "Parent note",+ "#foo(inheritable)": "false",+ "children": [+ {+ title: "Child note",+ "#foo": "false",+ }+ ]+ });+ const childNote = froca.getNoteFromCache(parentNote.children[0])!;+ expect(childNote.isLabelTruthy("foo")).toBe(false);+ await setBooleanWithInheritance(childNote, "foo", true);+ expect(server.remove).toHaveBeenCalledWith(`notes/${childNote.noteId}/attributes/${childNote.getLabel("foo")!.attributeId}`);+ });});diff --git a/apps/client/src/services/attributes.ts b/apps/client/src/services/attributes.tsindex 34c07d638a..2f0a1202d8 100644--- a/apps/client/src/services/attributes.ts+++ b/apps/client/src/services/attributes.ts@@ -48,7 +48,7 @@ export async function setBooleanWithInheritance(note: FNote, labelName: string,if (actualValue === value) return;if (value) {- if (note.getLabelValue(labelName) === "false") {+ if (note.getOwnedLabelValue(labelName) === "false") {// Remove the override so that the inherited true takes effect.removeOwnedLabelByName(note, labelName);} else {