mirror of
https://github.com/dergigi/boris.git
synced 2026-02-14 19:44:28 +01:00
debug(reading-position): add comprehensive logging to scheduleSave
Adding detailed logs to trace exactly what's happening when saves are attempted. This will help identify why saves aren't working.
This commit is contained in:
@@ -38,7 +38,10 @@ export const useReadingPosition = ({
|
||||
|
||||
// Throttled save function - saves at 3s intervals during scrolling
|
||||
const scheduleSave = useCallback((currentPosition: number) => {
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] 📞 scheduleSave called at ${Math.round(currentPosition * 100)}%, syncEnabled=${syncEnabled}, hasOnSave=${!!onSave}`)
|
||||
|
||||
if (!syncEnabled || !onSave) {
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] ⏭️ Save skipped: syncEnabled=${syncEnabled}, hasOnSave=${!!onSave}`)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -60,10 +63,12 @@ export const useReadingPosition = ({
|
||||
// Throttle: only schedule a save if one isn't already pending
|
||||
// This ensures saves happen at regular 3s intervals during continuous scrolling
|
||||
if (saveTimerRef.current) {
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] ⏳ Timer already pending, updated pending position to ${Math.round(currentPosition * 100)}%`)
|
||||
return // Already have a save scheduled, don't reset the timer
|
||||
}
|
||||
|
||||
const THROTTLE_MS = 3000
|
||||
console.log(`[reading-position] [${new Date().toISOString()}] ⏰ Scheduling save in ${THROTTLE_MS}ms`)
|
||||
saveTimerRef.current = setTimeout(() => {
|
||||
// Save the latest position, not the one from when timer was scheduled
|
||||
const positionToSave = pendingPositionRef.current
|
||||
|
||||
Reference in New Issue
Block a user