From 934043f858c96c84a07c6a558f43967d8bd24d4b Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 2 Oct 2025 09:15:04 +0200 Subject: [PATCH] fix: resolve loading state stuck issue - Remove loading check from early return condition - Add timeout to ensure loading state gets reset - Clear timeout when function completes - This should allow fetchBookmarks to run properly --- src/components/Bookmarks.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/Bookmarks.tsx b/src/components/Bookmarks.tsx index 498171fd..836a056a 100644 --- a/src/components/Bookmarks.tsx +++ b/src/components/Bookmarks.tsx @@ -75,8 +75,8 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { const fetchBookmarks = async () => { console.log('🔍 fetchBookmarks called, loading:', loading) - if (!relayPool || !activeAccount || loading) { - console.log('🔍 fetchBookmarks early return - relayPool:', !!relayPool, 'activeAccount:', !!activeAccount, 'loading:', loading) + if (!relayPool || !activeAccount) { + console.log('🔍 fetchBookmarks early return - relayPool:', !!relayPool, 'activeAccount:', !!activeAccount) return } @@ -84,6 +84,12 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { setLoading(true) console.log('🚀 NEW VERSION: Fetching bookmark list for pubkey:', activeAccount.pubkey) + // 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 relay URLs from the pool const relayUrls = Array.from(relayPool.relays.values()).map(relay => relay.url) @@ -184,10 +190,12 @@ const Bookmarks: React.FC = ({ relayPool, onLogout }) => { } setBookmarks([bookmark]) + clearTimeout(timeoutId) setLoading(false) } catch (error) { console.error('Failed to fetch bookmarks:', error) + clearTimeout(timeoutId) setLoading(false) } }