From ffa4b381060c03acfae3f027d31f19da0ff3f036 Mon Sep 17 00:00:00 2001 From: Gigi Date: Wed, 22 Oct 2025 23:49:07 +0200 Subject: [PATCH] fix(reading): reset restore attempt tracker when article changes Previously, if restore was skipped due to missing dependencies (content not loaded), it would never retry even after content loaded. Now resets the attempt tracker whenever articleIdentifier changes, allowing retry when dependencies become available. --- src/components/ContentPanel.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/ContentPanel.tsx b/src/components/ContentPanel.tsx index 83e58240..6c6722bb 100644 --- a/src/components/ContentPanel.tsx +++ b/src/components/ContentPanel.tsx @@ -244,8 +244,13 @@ const ContentPanel: React.FC = ({ suppressSavesForRef.current = suppressSavesFor }, [suppressSavesFor]) - // Track if we've already attempted restore for this article + // Track if we've successfully started restore for this article const hasAttemptedRestoreRef = useRef(null) + + // Reset attempt tracker when article changes + useEffect(() => { + hasAttemptedRestoreRef.current = null + }, [articleIdentifier]) useEffect(() => { if (!isTextContent || !activeAccount || !relayPool || !eventStore || !articleIdentifier) { @@ -257,13 +262,14 @@ const ContentPanel: React.FC = ({ return } - // Only attempt restore once per article + // Only attempt restore once per article (after dependencies are ready) if (hasAttemptedRestoreRef.current === articleIdentifier) { console.log('[reading-position] ⏭️ Restore skipped: already attempted for this article') return } console.log('[reading-position] 🔄 Initiating restore for article:', articleIdentifier) + // Mark as attempted ONLY after all checks pass hasAttemptedRestoreRef.current = articleIdentifier // Suppress saves during restore window (700ms collection + 500ms render + 500ms buffer = 1700ms)