From 0a78d19195666880f5943b09daa953bddc18a04f Mon Sep 17 00:00:00 2001 From: Gigi Date: Sun, 5 Oct 2025 03:06:36 +0100 Subject: [PATCH] refactor: simplify Bookmarks.tsx to meet 210 line limit - Remove verbose console.log statements - Simplify handlers and remove unnecessary blank lines - Condense font loading logic - Keep code DRY and simple - File now at exactly 210 lines --- src/components/Bookmarks.tsx | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index c5871247..893c441a 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -48,16 +48,10 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { const eventStore = useEventStore() useEffect(() => { - console.log('Bookmarks useEffect triggered') - console.log('relayPool:', !!relayPool) - console.log('activeAccount:', !!activeAccount) if (relayPool && activeAccount) { - console.log('Starting to fetch bookmarks and highlights...') handleFetchBookmarks() handleFetchHighlights() handleLoadSettings() - } else { - console.log('Not fetching bookmarks - missing dependencies') } }, [relayPool, activeAccount?.pubkey]) @@ -68,35 +62,19 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { if (settings.highlightsCollapsed !== undefined) setIsHighlightsCollapsed(settings.highlightsCollapsed) if (settings.readingFont) { loadFont(settings.readingFont) - // Apply font to content panel - const fontFamily = getFontFamily(settings.readingFont) - document.documentElement.style.setProperty('--reading-font', fontFamily) + document.documentElement.style.setProperty('--reading-font', getFontFamily(settings.readingFont)) } }, [settings]) const handleFetchBookmarks = async () => { - console.log('🔍 fetchBookmarks called, loading:', loading) - if (!relayPool || !activeAccount) { - console.log('🔍 fetchBookmarks early return - relayPool:', !!relayPool, 'activeAccount:', !!activeAccount) - return - } - - // Set a timeout to ensure loading state gets reset - const timeoutId = setTimeout(() => { - console.log('⏰ Timeout reached, resetting loading state') - setLoading(false) - }, 15000) // 15 second timeout - - // Get the full account object with extension capabilities + if (!relayPool || !activeAccount) return + const timeoutId = setTimeout(() => setLoading(false), 15000) const fullAccount = accountManager.getActive() await fetchBookmarks(relayPool, fullAccount || activeAccount, setBookmarks, setLoading, timeoutId) } const handleFetchHighlights = async () => { - if (!relayPool || !activeAccount) { - return - } - + if (!relayPool || !activeAccount) return setHighlightsLoading(true) try { const fetchedHighlights = await fetchHighlights(relayPool, activeAccount.pubkey) @@ -157,8 +135,6 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { } } - - if (loading) { return (