From c1a23c1f8f4d90a5d915fd3d51765bb49ee253d0 Mon Sep 17 00:00:00 2001 From: Gigi Date: Wed, 22 Oct 2025 23:29:29 +0200 Subject: [PATCH] fix(reading): prevent restore effect from restarting during content load Track whether we've already attempted restore for each article using a ref. Prevents the effect from restarting multiple times as html/markdown/loading state changes during initial page load, which was stopping the stabilization timer before it could complete. --- src/components/ContentPanel.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/ContentPanel.tsx b/src/components/ContentPanel.tsx index 982a2c3d..56510af6 100644 --- a/src/components/ContentPanel.tsx +++ b/src/components/ContentPanel.tsx @@ -225,6 +225,9 @@ const ContentPanel: React.FC = ({ suppressSavesForRef.current = suppressSavesFor }, [suppressSavesFor]) + // Track if we've already attempted restore for this article + const hasAttemptedRestoreRef = useRef(null) + useEffect(() => { if (!isTextContent || !activeAccount || !relayPool || !eventStore || !articleIdentifier) { console.log('[reading-position] ⏭️ Restore skipped: missing dependencies or not text content') @@ -235,7 +238,14 @@ const ContentPanel: React.FC = ({ return } + // Only attempt restore once per article + 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) + hasAttemptedRestoreRef.current = articleIdentifier const collector = collectReadingPositionsOnce({ relayPool, eventStore,