fix(plex): Esc/Backspace actually cancels the auto-skip countdown
Cancelling only blanked skipProgress and flagged the marker — it never stopped the running interval, so the next tick (~100ms later) re-set the progress and the skip fired anyway. Hold the interval id in a ref and clear it on cancel (and null it on completion/cleanup), so Esc/Backspace truly stops the countdown; the Skip button stays for a manual skip.
This commit is contained in:
parent
089eab76e4
commit
dcdf48a811
1 changed files with 13 additions and 1 deletions
|
|
@ -796,6 +796,9 @@ export default function PlexPlayer({ itemId, onClose, queue }: Props) {
|
|||
const [skipProgress, setSkipProgress] = useState<number | null>(null);
|
||||
skipProgressRef.current = skipProgress;
|
||||
const cancelledMarkerRef = useRef<string | null>(null);
|
||||
// The running countdown interval, so cancelAutoSkip can actually STOP it — clearing skipProgress
|
||||
// alone left the interval ticking, which re-set the progress ~100ms later and skipped anyway.
|
||||
const skipTimerRef = useRef<number | null>(null);
|
||||
const doSkip = useCallback(
|
||||
(m: PlexMarker) => {
|
||||
setSkipProgress(null);
|
||||
|
|
@ -807,6 +810,10 @@ export default function PlexPlayer({ itemId, onClose, queue }: Props) {
|
|||
const cancelAutoSkip = useCallback(() => {
|
||||
const m = activeMarkerRef.current;
|
||||
if (m) cancelledMarkerRef.current = `${m.type}-${m.start_s}`; // don't re-arm this same marker
|
||||
if (skipTimerRef.current) {
|
||||
window.clearInterval(skipTimerRef.current); // actually stop the countdown, not just blank it
|
||||
skipTimerRef.current = null;
|
||||
}
|
||||
setSkipProgress(null);
|
||||
}, []);
|
||||
cancelAutoSkipRef.current = cancelAutoSkip;
|
||||
|
|
@ -828,10 +835,15 @@ export default function PlexPlayer({ itemId, onClose, queue }: Props) {
|
|||
setSkipProgress(p);
|
||||
if (p >= 1) {
|
||||
window.clearInterval(iv);
|
||||
skipTimerRef.current = null;
|
||||
doSkip(m);
|
||||
}
|
||||
}, 100);
|
||||
return () => window.clearInterval(iv);
|
||||
skipTimerRef.current = iv;
|
||||
return () => {
|
||||
window.clearInterval(iv);
|
||||
skipTimerRef.current = null;
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [activeMarker?.type, activeMarker?.start_s, prefs.autoSkipIntro, prefs.autoSkipCredits, prefs.autoSkipDelay, doSkip]);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue