Save Progress During Reading
Save Progress During Reading
Task
Persist progress as the user reads without creating a request for every tiny rendering event.
Call the progress API from the Reader after a meaningful relocation. Debounce writes so rapid navigation produces one final update.
A simple debounce boundary:
const timer = window.setTimeout(() => {
saveProgress({ cfi, percentage });
}, 500);
return () => window.clearTimeout(timer);
Preserve the latest CFI when the Reader unmounts so a final save can be attempted if your lifecycle allows it.
Only send progress for the currently authenticated user and current Book.
Test
Read forward, leave the Reader, then inspect the ReadingProgress record.
Navigate quickly several times and confirm requests are not fired continuously for every render.
Checkpoint
Readly persists meaningful reading movement without turning normal reading into a stream of database writes.