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(note_tree): subtree hidden cannot be overridden through inheritance
Elian Dorand77d30f29e07
diff --git a/apps/client/src/entities/fnote.ts b/apps/client/src/entities/fnote.tsindex 644ea22284..83255e4889 100644--- a/apps/client/src/entities/fnote.ts+++ b/apps/client/src/entities/fnote.ts@@ -616,7 +616,7 @@ export default class FNote {}isFolder() {- if (this.hasLabel("subtreeHidden")) return false;+ if (this.isLabelTruthy("subtreeHidden")) return false;if (this.type === "search") return true;return this.getFilteredChildBranches().length > 0;}diff --git a/apps/client/src/menus/tree_context_menu.ts b/apps/client/src/menus/tree_context_menu.tsindex d7ff4b777b..551732e9db 100644--- a/apps/client/src/menus/tree_context_menu.ts+++ b/apps/client/src/menus/tree_context_menu.ts@@ -72,7 +72,7 @@ export default class TreeContextMenu implements SelectMenuItemEventListener<Treeconst noSelectedNotes = selNodes.length === 0 || (selNodes.length === 1 && selNodes[0] === this.node);const notSearch = note?.type !== "search";- const hasSubtreeHidden = note?.hasLabel("subtreeHidden") ?? false;+ const hasSubtreeHidden = note?.isLabelTruthy("subtreeHidden") ?? false;const notOptionsOrHelp = !note?.noteId.startsWith("_options") && !note?.noteId.startsWith("_help");const parentNotSearch = !parentNote || parentNote.type !== "search";const insertNoteAfterEnabled = isNotRoot && !isHoisted && parentNotSearch;diff --git a/apps/client/src/services/attributes.ts b/apps/client/src/services/attributes.tsindex 359e7ab433..3b45d2d460 100644--- a/apps/client/src/services/attributes.ts+++ b/apps/client/src/services/attributes.ts@@ -37,6 +37,8 @@ export async function setRelation(noteId: string, name: string, value: string =* will be removed. If the label is inherited from a parent note, it will be overridden to `false`. If the label does* not exist, it will be added with an empty value.*+ * When checking if the boolean value is set, don't use `note.hasLabel`; instead use `note.isLabelTruthy`.+ ** @param note the note on which to toggle the label.* @param labelName the name of the label to toggle.*/diff --git a/apps/client/src/widgets/note_tree.ts b/apps/client/src/widgets/note_tree.tsindex d541e6deb9..34aa0548c2 100644--- a/apps/client/src/widgets/note_tree.ts+++ b/apps/client/src/widgets/note_tree.ts@@ -556,7 +556,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {branchService.moveAfterBranch(selectedBranchIds, node.data.branchId);} else if (data.hitMode === "over") {const targetNote = froca.getNoteFromCache(node.data.noteId);- if (targetNote?.hasLabel("subtreeHidden")) {+ if (targetNote?.isLabelTruthy("subtreeHidden")) {toastService.showPersistent({id: `subtree-hidden-moved`,title: t("note_tree.subtree-hidden-moved-title", { count: selectedBranchIds.length, title: targetNote.title }),@@ -724,7 +724,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {childBranches = childBranches.slice(0, MAX_SEARCH_RESULTS_IN_TREE);}- if (parentNote.hasLabel("subtreeHidden")) {+ if (parentNote.isLabelTruthy("subtreeHidden")) {// If we have a spotlighted note path, show only the child that leads to itif (this.spotlightedNotePath) {const spotlightPathSegments = this.spotlightedNotePath.split('/');@@ -772,7 +772,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {}const parentNote = froca.getNoteFromCache(branch.parentNoteId);- if (parentNote?.hasLabel("subtreeHidden")) {+ if (parentNote?.isLabelTruthy("subtreeHidden")) {const parentNode = node.getParent();if (parentNode) {parentNode.setActive(true);@@ -1040,7 +1040,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {// The child note can be part of a note with #subtreeHidden, case in which we need to "spotlight" it.const parentNote = froca.getNoteFromCache(parentNode.data.noteId);- if (parentNote?.hasLabel("subtreeHidden")) {+ if (parentNote?.isLabelTruthy("subtreeHidden")) {// Enable spotlight mode and reload the parent to show only the path to this notethis.spotlightedNotePath = notePath;await parentNode.load(true);@@ -1924,7 +1924,7 @@ function buildEnhanceTitle() {}// TODO: Deduplicate with server's notes.ts#getAndValidateParent- const isSubtreeHidden = note.hasLabel("subtreeHidden");+ const isSubtreeHidden = note.isLabelTruthy("subtreeHidden");if (!["search", "launcher"].includes(note.type)&& !note.isOptions()&& !note.isLaunchBarConfig()