fix(hidden_subtree): attribute of wrong type (relation vs label) causing issues

This commit is contained in:
Elian Doran 2026-02-23 18:45:20 +02:00
parent 8d233e66e1
commit 7ec718218e
No known key found for this signature in database
2 changed files with 15 additions and 2 deletions

View File

@ -192,5 +192,16 @@ describe("Hidden Subtree", () => {
llmNote = becca.getNote(noteId);
expect(llmNote).toBeFalsy();
});
it("fixes attribute of wrong type", () => {
const template = becca.getNoteOrThrow("_template_table");
cls.init(() => {
template.setAttribute("relation", "template", "root");
hiddenSubtreeService.checkHiddenSubtree();
});
const attr = template.getAttributes().find(a => a.name === "template");
expect(attr).toBeDefined();
expect(attr?.type).toBe("label");
});
});
});

View File

@ -467,8 +467,10 @@ function checkHiddenSubtreeRecursively(parentNoteId: string, item: HiddenSubtree
}
// Ensure value is consistent.
if (attribute.value !== attrDef.value) {
note.setAttributeValueById(attribute.attributeId, attrDef.value);
if (attribute.value !== attrDef.value || attribute.type !== attrDef.type) {
attribute.type = attrDef.type;
attribute.value = attrDef.value ?? "";
attribute.save();
}
}
}