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
feat(mobile/nav): basic handling of hidden subtree
Elian Doran547f005bb43a
diff --git a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.cssindex 0c8807c3f5..6865a435fc 100644--- a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css+++ b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.css@@ -261,3 +261,16 @@font-size: 1.4em;opacity: 0.5;}++.mobile-navigator-row-hidden-badge {+ flex: 0 0 auto;+ min-width: 1.6em;+ padding: 2px 8px;+ border-radius: 999px;+ background: var(--accented-background-color, var(--hover-item-background-color));+ color: var(--muted-text-color, var(--main-text-color));+ font-size: 0.75em;+ font-weight: 600;+ text-align: center;+ line-height: 1.2;+}diff --git a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsxindex f10998f163..284dfff6b9 100644--- a/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx+++ b/apps/client/src/widgets/mobile_widgets/MobileNoteNavigator.tsx@@ -17,6 +17,7 @@ import {useNote,useNoteColorClass,useNoteIcon,+ useNoteLabelBoolean,useNoteTitle,useTriliumEvent,useTriliumOptionBool@@ -323,7 +324,13 @@ interface NavigatorRowProps {function NavigatorRow({ note, parentNoteId, childNotePath, isActive, isPending, onDrill, onOpen, parentComponent }: NavigatorRowProps) {const icon = useNoteIcon(note);- const hasChildren = note.hasChildren();+ const [isSubtreeHidden] = useNoteLabelBoolean(note, "subtreeHidden");+ const rawChildCount = note.getChildNoteIds().length;+ // Notes marked with `#subtreeHidden` hide their children from the tree, so+ // the navigator treats them as leaves (open-on-tap) and shows a badge with+ // the hidden count instead of the drill-in chevron.+ const hasChildren = note.hasChildren() && !isSubtreeHidden;+ const showHiddenBadge = isSubtreeHidden && rawChildCount > 0;const colorClass = useNoteColorClass(note);const title = useNoteTitle(note.noteId, parentNoteId) ?? note.title;const contextHandler = useMemo(@@ -347,6 +354,14 @@ function NavigatorRow({ note, parentNoteId, childNotePath, isActive, isPending,><Icon icon={icon ?? "bx bx-note"} className="mobile-navigator-row-icon" /><span className="mobile-navigator-row-title">{title}</span>+ {showHiddenBadge && (+ <span+ className="mobile-navigator-row-hidden-badge"+ title={t("note_tree.subtree-hidden-tooltip", { count: rawChildCount })}+ >+ {rawChildCount}+ </span>+ )}{isPending ? (<Icon icon="bx bx-loader bx-spin" className="mobile-navigator-row-chevron" />) : hasChildren ? (