diff --git a/ui/src/lib/components/AudioPlayer.svelte b/ui/src/lib/components/AudioPlayer.svelte index 976c39a..4066c2d 100644 --- a/ui/src/lib/components/AudioPlayer.svelte +++ b/ui/src/lib/components/AudioPlayer.svelte @@ -78,11 +78,16 @@ }); // Reset next-chapter prefetch state when this chapter changes (new page). - // We only reset if the prefetch is for a *different* chapter than nextChapter - // (i.e. stale data from a prior page). + // Only reset if the prefetch belongs to neither the current chapter + // (about to be consumed by startPlayback) nor the next chapter (still valid). + // Any other value means stale data from a previous page. $effect(() => { const prefetchedFor = audioStore.nextChapterPrefetched; - if (prefetchedFor !== null && prefetchedFor !== (nextChapter ?? null)) { + if ( + prefetchedFor !== null && + prefetchedFor !== chapter && + prefetchedFor !== (nextChapter ?? null) + ) { audioStore.resetNextPrefetch(); } });