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(breadcrumb): prefer workspace icon class
Elian Doran6d4e52c928e2
diff --git a/apps/client/src/widgets/layout/Breadcrumb.tsx b/apps/client/src/widgets/layout/Breadcrumb.tsxindex 0135cbb501..11dfafa748 100644--- a/apps/client/src/widgets/layout/Breadcrumb.tsx+++ b/apps/client/src/widgets/layout/Breadcrumb.tsx@@ -14,7 +14,7 @@ import ActionButton from "../react/ActionButton";import { Badge } from "../react/Badge";import Dropdown from "../react/Dropdown";import { FormListItem } from "../react/FormList";-import { useChildNotes, useNote, useNoteLabel, useNoteLabelBoolean, useNoteProperty } from "../react/hooks";+import { useChildNotes, useNote, useNoteIcon, useNoteLabel, useNoteLabelBoolean, useNoteProperty } from "../react/hooks";import Icon from "../react/Icon";import NoteLink from "../react/NoteLink";@@ -84,14 +84,16 @@ function BreadcrumbRoot({ noteContext }: { noteContext: NoteContext | undefinedfunction BreadcrumbHoistedNoteRoot({ noteId }: { noteId: string }) {const note = useNote(noteId);+ const noteIcon = useNoteIcon(note);const [ workspace ] = useNoteLabelBoolean(note, "workspace");+ const [ workspaceIconClass ] = useNoteLabel(note, "workspaceIconClass");// Hoisted workspace shows both text and icon and a way to exit easily out of the hoisting.return (note &&<><BadgeclassName="badge-hoisted"- icon={workspace ? "bx bx-folder-open" : "bx bxs-chevrons-up"}+ icon={workspace ? (workspaceIconClass || noteIcon) : "bx bxs-chevrons-up"}text={workspace ? t("breadcrumb.workspace_badge") : t("breadcrumb.hoisted_badge")}tooltip={t("breadcrumb.hoisted_badge_title")}onClick={() => hoisted_note.unhoist()}diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsxindex 0d8b16bbfd..535a797f5b 100644--- a/apps/client/src/widgets/react/hooks.tsx+++ b/apps/client/src/widgets/react/hooks.tsx@@ -1039,3 +1039,13 @@ export function useNote(noteId: string | null | undefined, silentNotFoundError =}return undefined;}++export function useNoteIcon(note: FNote | null | undefined) {+ const [ icon, setIcon ] = useState(note?.getIcon());+ const iconClass = useNoteLabel(note, "iconClass");+ useEffect(() => {+ setIcon(note?.getIcon());+ }, [ note, iconClass ]);++ return icon;+}