From 6d4e52c928e2841ef8ad5d3b7ee1a0c9ca9ccf51 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 15 Dec 2025 16:31:43 +0200 Subject: [PATCH] feat(breadcrumb): prefer workspace icon class --- apps/client/src/widgets/layout/Breadcrumb.tsx | 6 ++++-- apps/client/src/widgets/react/hooks.tsx | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/client/src/widgets/layout/Breadcrumb.tsx b/apps/client/src/widgets/layout/Breadcrumb.tsx index 0135cbb50..11dfafa74 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 | undefined function 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 && <> hoisted_note.unhoist()} diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index 0d8b16bbf..535a797f5 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; +}