mirror of
https://github.com/dergigi/boris.git
synced 2026-01-20 15:24:58 +01:00
debug(reading): add ISO timestamps to all position logs
Makes it easy to see exact timing of saves and identify if debouncing is working correctly.
This commit is contained in:
@@ -179,7 +179,7 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
||||
const scrollTop = window.pageYOffset || document.documentElement.scrollTop
|
||||
|
||||
try {
|
||||
console.log('[reading-position] 🚀 Publishing position', Math.round(position * 100) + '% to relays...')
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] 🚀 Publishing position ${Math.round(position * 100)}% to relays...`)
|
||||
const factory = new EventFactory({ signer: activeAccount })
|
||||
await saveReadingPosition(
|
||||
relayPool,
|
||||
@@ -192,9 +192,9 @@ const ContentPanel: React.FC<ContentPanelProps> = ({
|
||||
scrollTop
|
||||
}
|
||||
)
|
||||
console.log('[reading-position] ✅ Position published successfully')
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] ✅ Position published successfully`)
|
||||
} catch (error) {
|
||||
console.error('[reading-position] ❌ Failed to save reading position:', error)
|
||||
console.error(`[reading-position] [${new Date().toISOString()}] ❌ Failed to save reading position:`, error)
|
||||
}
|
||||
}, [activeAccount, relayPool, eventStore, articleIdentifier, settings?.syncReadingPosition, html, markdown])
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ export const useReadingPosition = ({
|
||||
const suppressSavesFor = useCallback((ms: number) => {
|
||||
const until = Date.now() + ms
|
||||
suppressUntilRef.current = until
|
||||
console.log('[reading-position] 🛡️ Suppressing saves for', ms, 'ms until', new Date(until).toISOString())
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] 🛡️ Suppressing saves for ${ms}ms until ${new Date(until).toISOString()}`)
|
||||
}, [])
|
||||
|
||||
// Debounced save function - simple 2s debounce
|
||||
@@ -49,7 +49,7 @@ export const useReadingPosition = ({
|
||||
clearTimeout(saveTimerRef.current)
|
||||
saveTimerRef.current = null
|
||||
}
|
||||
console.log('[reading-position] 💾 Instant save at 100% completion')
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] 💾 Instant save at 100% completion`)
|
||||
lastSavedPosition.current = 1
|
||||
hasSavedOnce.current = true
|
||||
lastSavedAtRef.current = Date.now()
|
||||
@@ -71,9 +71,9 @@ export const useReadingPosition = ({
|
||||
}
|
||||
|
||||
const DEBOUNCE_MS = 3000 // Save max every 3 seconds
|
||||
console.log('[reading-position] ⏱️ Debouncing save for', DEBOUNCE_MS, 'ms (pos:', Math.round(currentPosition * 100) + '%)')
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] ⏱️ Debouncing save for ${DEBOUNCE_MS}ms (pos: ${Math.round(currentPosition * 100)}%)`)
|
||||
saveTimerRef.current = setTimeout(() => {
|
||||
console.log('[reading-position] 💾 Auto-save at', Math.round(currentPosition * 100) + '%')
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] 💾 Auto-save at ${Math.round(currentPosition * 100)}%`)
|
||||
lastSavedPosition.current = currentPosition
|
||||
hasSavedOnce.current = true
|
||||
lastSavedAtRef.current = Date.now()
|
||||
@@ -89,7 +89,7 @@ export const useReadingPosition = ({
|
||||
clearTimeout(saveTimerRef.current)
|
||||
saveTimerRef.current = null
|
||||
}
|
||||
console.log('[reading-position] 💾 saveNow() called at', Math.round(position * 100) + '%')
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] 💾 saveNow() called at ${Math.round(position * 100)}%`)
|
||||
lastSavedPosition.current = position
|
||||
hasSavedOnce.current = true
|
||||
lastSavedAtRef.current = Date.now()
|
||||
@@ -126,7 +126,7 @@ export const useReadingPosition = ({
|
||||
scheduleSave(clampedProgress)
|
||||
} else {
|
||||
const remainingMs = suppressUntilRef.current - Date.now()
|
||||
console.log('[reading-position] 🛡️ Save suppressed (', remainingMs, 'ms remaining) at', Math.round(clampedProgress * 100) + '%')
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] 🛡️ Save suppressed (${remainingMs}ms remaining) at ${Math.round(clampedProgress * 100)}%`)
|
||||
}
|
||||
|
||||
// Completion detection with 2s hold at 100%
|
||||
|
||||
Reference in New Issue
Block a user