debug: add logs to show why reading position saves are skipped

- Log when scheduleSave returns early (syncEnabled false, no onSave callback)
- Log when position is too low (<5%)
- Log when change is not significant enough (<1%)
- Log ContentPanel sync status (enabled, settings, requirements)
- This will help diagnose why no events are being created
This commit is contained in:
Gigi
2025-10-19 11:41:38 +02:00
parent 205879f948
commit 3a10ac8691
2 changed files with 30 additions and 4 deletions

View File

@@ -199,11 +199,24 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
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(() => {

View File

@@ -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) {