From 0fff5ad35da812698062009094bdefe1549319c7 Mon Sep 17 00:00:00 2001 From: npeter83 Date: Sun, 5 Jul 2026 19:49:39 +0200 Subject: [PATCH] fix(player): keep playing the current video when it leaves the live feed queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Auto-marking a video watched near its end invalidates the feed query; the refetched/reordered queue can no longer contain the playing item, so findIndex returned -1 and the active item fell back to queue[0] — silently jumping playback to an unrelated video and defeating Loop "One" (and auto-advance:off). Pin the last resolved video in a ref and keep playing it when it drops out of the queue instead of snapping to queue[0]. --- VERSION | 2 +- frontend/src/components/PlayerModal.tsx | 15 ++++++++++++--- frontend/src/lib/releaseNotes.ts | 8 ++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 610e287..c86a09d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.23.1 +0.23.2 \ No newline at end of file diff --git a/frontend/src/components/PlayerModal.tsx b/frontend/src/components/PlayerModal.tsx index 76b41eb..7320171 100644 --- a/frontend/src/components/PlayerModal.tsx +++ b/frontend/src/components/PlayerModal.tsx @@ -93,9 +93,18 @@ export default function PlayerModal({ // `video` in the queue (the feed passes its whole list + the clicked video, no index). startIndex != null ? queue?.[startIndex]?.id ?? video.id : video.id ); - let index = queue ? queue.findIndex((v) => v.id === playingId) : 0; - if (index < 0) index = 0; - const active = queue && queue[index] ? queue[index] : video; + // Resolve the playing item from the LIVE queue so prev/next + the N/M counter track it. But + // the feed query reorders/refetches under us — e.g. auto-marking the current video watched near + // its end invalidates the feed — and the playing item can drop OUT of the loaded queue. When + // that happens we must KEEP PLAYING it, not snap back to queue[0] (which would silently jump to + // an unrelated video mid-playback, ignoring loop/auto-advance). So pin the last resolved video + // in a ref and fall back to it; neighbour stepping just treats it as sitting before queue[0]. + const foundIndex = queue ? queue.findIndex((v) => v.id === playingId) : -1; + const inQueue = foundIndex >= 0; + const activeRef = useRef