mirror of
https://github.com/dergigi/boris.git
synced 2026-02-22 07:25:03 +01:00
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.
This commit is contained in:
@@ -225,6 +225,9 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
||||
suppressSavesForRef.current = suppressSavesFor
|
||||
}, [suppressSavesFor])
|
||||
|
||||
// Track if we've already attempted restore for this article
|
||||
const hasAttemptedRestoreRef = useRef<string | null>(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<ContentPanelProps> = ({
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user