From fee538f044da6668faf11c61829d042d3628914c Mon Sep 17 00:00:00 2001 From: Jose Henrique Date: Fri, 10 Jul 2026 21:18:26 -0300 Subject: [PATCH] fixing issue with icon picker --- components/WebsiteEditModal.tsx | 10 +++++++--- project-context.md | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/WebsiteEditModal.tsx b/components/WebsiteEditModal.tsx index 9b3c9fd..186f4b4 100644 --- a/components/WebsiteEditModal.tsx +++ b/components/WebsiteEditModal.tsx @@ -33,12 +33,16 @@ const WebsiteEditModal: React.FC = ({ website, edit, onCl const [icon, setIcon] = useState(website ? website.icon : ''); const [iconQuery, setIconQuery] = useState(''); const [filteredIcons, setFilteredIcons] = useState([]); - const [iconMetadata, setIconMetadata] = useState([]); - const [iconsFetched, setIconsFetched] = useState(false); + const [iconMetadata, setIconMetadata] = useState(() => iconMetadataCache ?? []); + const [iconsFetched, setIconsFetched] = useState(() => iconMetadataCache !== null); const debounceRef = useRef(null); const ensureIconMetadata = () => { - if (iconMetadataCache || iconsFetched) return; + if (iconMetadataCache) { + setIconMetadata(iconMetadataCache); + return; + } + if (iconsFetched) return; setIconsFetched(true); fetch('/icon-metadata.json', { cache: 'force-cache' }) .then(response => response.json()) diff --git a/project-context.md b/project-context.md index 82dd898..6cbfeed 100644 --- a/project-context.md +++ b/project-context.md @@ -68,7 +68,7 @@ Performance notes: - `Clock` updates on the minute boundary (one `setTimeout` → `setInterval(60_000)`) instead of every second. - `jsping` cancels its 5s timeout on image resolve/error and nulls the `Image` handlers, preventing leaks across ping cycles. - `ServerWidget` batches pending-status updates into one `setState` and depends on a stable servers signature (ids+addresses) so unrelated config edits don't restart pings. -- Icon metadata (`/icon-metadata.json`) is module-level cached, fetched lazily on first focus of the icon field with `cache: 'force-cache'`, filter debounced ~150ms, and color variants are expanded lazily during filtering rather than upfront. +- Icon metadata (`/icon-metadata.json`) is module-level cached and hydrated into each icon-picker instance, fetched lazily on first focus of the icon field with `cache: 'force-cache'`, filter debounced ~150ms, and color variants are expanded lazily during filtering rather than upfront. - `Wallpaper` caches resolved wallpaper URLs in a module-level `Map`; its image transition and readability overlay classes live in `index.css`. Planned / To-do (tracked in `README.md`):