fix: clear reader content immediately when naddr changes

Prevent showing stale images from previous articles by clearing
readerContent at the start of the effect when navigating to a new article.
This commit is contained in:
Gigi
2025-10-31 01:31:30 +01:00
parent cc722c2599
commit 81597fbb6d

View File

@@ -76,11 +76,16 @@ export function useArticleLoader({
// First check: naddr is required // First check: naddr is required
if (!naddr) { if (!naddr) {
console.log('[article-loader] Skipping load - missing naddr') console.log('[article-loader] Skipping load - missing naddr')
setReaderContent(undefined)
return return
} }
console.log('[article-loader] Starting load for naddr:', naddr) console.log('[article-loader] Starting load for naddr:', naddr)
// Clear readerContent immediately to prevent showing stale content from previous article
// This ensures images from previous articles don't flash briefly
setReaderContent(undefined)
// Synchronously check cache sources BEFORE checking relayPool // Synchronously check cache sources BEFORE checking relayPool
// This prevents showing loading skeletons when content is immediately available // This prevents showing loading skeletons when content is immediately available
// and fixes the race condition where relayPool isn't ready yet // and fixes the race condition where relayPool isn't ready yet