ux(bookmarks): avoid clearing list when no new events; decouple refetch from route changes

This commit is contained in:
Gigi
2025-10-12 23:26:18 +02:00
parent d2ebcd8fbe
commit b3fc9bb5c3
2 changed files with 9 additions and 3 deletions

View File

@@ -106,15 +106,21 @@ export const useBookmarksData = ({
}
}, [relayPool, activeAccount, isRefreshing, handleFetchBookmarks, handleFetchHighlights, handleFetchContacts])
// Load initial data
// Load initial data (avoid clearing on route-only changes)
useEffect(() => {
if (!relayPool || !activeAccount) return
// Only (re)fetch bookmarks when account or relayPool changes, not on naddr route changes
handleFetchBookmarks()
}, [relayPool, activeAccount, handleFetchBookmarks])
// Fetch highlights/contacts independently to avoid disturbing bookmarks
useEffect(() => {
if (!relayPool || !activeAccount) return
if (!naddr) {
handleFetchHighlights()
}
handleFetchContacts()
}, [relayPool, activeAccount, naddr, handleFetchBookmarks, handleFetchHighlights, handleFetchContacts])
}, [relayPool, activeAccount, naddr, handleFetchHighlights, handleFetchContacts])
return {
bookmarks,

View File

@@ -73,7 +73,7 @@ export const fetchBookmarks = async (
const bookmarkListEvents = dedupeNip51Events(rawEvents)
console.log('📋 After deduplication:', bookmarkListEvents.length, 'bookmark events')
if (bookmarkListEvents.length === 0) {
setBookmarks([])
// Keep existing bookmarks visible; do not clear list if nothing new found
return
}
// Aggregate across events