From ba699f9842095502e087ac1b6497e0c4484e823f Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 26 Dec 2025 21:01:19 +0200 Subject: [PATCH] refactor(note_icon): split filter content into a component --- apps/client/src/widgets/note_icon.tsx | 47 +++++++++++++++++---------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/apps/client/src/widgets/note_icon.tsx b/apps/client/src/widgets/note_icon.tsx index 93ed591a2..44cbf67c4 100644 --- a/apps/client/src/widgets/note_icon.tsx +++ b/apps/client/src/widgets/note_icon.tsx @@ -58,7 +58,7 @@ function NoteIconList({ note }: { note: FNote }) { const searchBoxRef = useRef(null); const [ search, setSearch ] = useState(); const [ iconData, setIconData ] = useState(); - const [ filterByPrefix, setFilterByIconPack ] = useState(null); + const [ filterByPrefix, setFilterByPrefix ] = useState(null); useEffect(() => { async function loadIcons() { @@ -134,23 +134,7 @@ function NoteIconList({ note }: { note: FNote }) { noDropdownListStyle iconAction > - setFilterByIconPack(null)} - >{t("note_icon.filter-none")} - setFilterByIconPack("bx")} - >{t("note_icon.filter-default")} - - - {glob.iconRegistry.sources.map(({ prefix, name }) => ( - setFilterByIconPack(prefix)} - checked={filterByPrefix === prefix} - >{name} - ))} + @@ -192,6 +176,33 @@ function NoteIconList({ note }: { note: FNote }) { ); } +function IconFilterContent({ filterByPrefix, setFilterByPrefix }: { + filterByPrefix: string | null; + setFilterByPrefix: (value: string | null) => void; +}) { + return ( + <> + setFilterByPrefix(null)} + >{t("note_icon.filter-none")} + setFilterByPrefix("bx")} + >{t("note_icon.filter-default")} + + + {glob.iconRegistry.sources.map(({ prefix, name }) => ( + setFilterByPrefix(prefix)} + checked={filterByPrefix === prefix} + >{name} + ))} + + ); +} + async function getIconToCountMap() { if (!iconToCountCache) { iconToCountCache = server.get("other/icon-usage");