diff --git a/src/components/ContentPanel.tsx b/src/components/ContentPanel.tsx index c24db06c..22a89933 100644 --- a/src/components/ContentPanel.tsx +++ b/src/components/ContentPanel.tsx @@ -199,11 +199,24 @@ const ContentPanel: React.FC = ({ onReadingComplete: () => { // Auto-mark as read when reading is complete (if enabled in settings) if (activeAccount && !isMarkedAsRead && settings?.autoMarkAsReadOnCompletion) { - console.log('📖 [ContentPanel] Auto-marking as read on completion') + console.log('[progress] 📖 Auto-marking as read on completion') handleMarkAsRead() } } }) + + // Log sync status when it changes + useEffect(() => { + console.log('[progress] 📊 ContentPanel reading position sync status:', { + enabled: isTextContent, + syncEnabled: settings?.syncReadingPosition, + hasAccount: !!activeAccount, + hasRelayPool: !!relayPool, + hasEventStore: !!eventStore, + hasArticleIdentifier: !!articleIdentifier, + currentProgress: progressPercentage + '%' + }) + }, [isTextContent, settings?.syncReadingPosition, activeAccount, relayPool, eventStore, articleIdentifier, progressPercentage]) // Load saved reading position when article loads useEffect(() => { diff --git a/src/hooks/useReadingPosition.ts b/src/hooks/useReadingPosition.ts index 7fa23988..bb635089 100644 --- a/src/hooks/useReadingPosition.ts +++ b/src/hooks/useReadingPosition.ts @@ -27,17 +27,30 @@ export const useReadingPosition = ({ // Debounced save function const scheduleSave = useCallback((currentPosition: number) => { - if (!syncEnabled || !onSave) return + if (!syncEnabled || !onSave) { + console.log('[progress] ⏭️ scheduleSave skipped:', { syncEnabled, hasOnSave: !!onSave, position: Math.round(currentPosition * 100) + '%' }) + return + } // Don't save if position is too low (< 5%) - if (currentPosition < 0.05) return + if (currentPosition < 0.05) { + console.log('[progress] ⏭️ Position too low to save:', Math.round(currentPosition * 100) + '%') + return + } // Don't save if position hasn't changed significantly (less than 1%) // But always save if we've reached 100% (completion) const hasSignificantChange = Math.abs(currentPosition - lastSavedPosition.current) >= 0.01 const hasReachedCompletion = currentPosition === 1 && lastSavedPosition.current < 1 - if (!hasSignificantChange && !hasReachedCompletion) return + if (!hasSignificantChange && !hasReachedCompletion) { + console.log('[progress] ⏭️ No significant change:', { + current: Math.round(currentPosition * 100) + '%', + last: Math.round(lastSavedPosition.current * 100) + '%', + diff: Math.abs(currentPosition - lastSavedPosition.current) + }) + return + } // Clear existing timer if (saveTimerRef.current) {