fix(player): clamp custom delay input and align preview with armed timer (#967)

* fix(player): clamp custom delay input and align preview with armed timer

Reject absurd custom minute values that overflow setTimeout, share one
delay helper between the modal preview and schedule actions, and refresh
countdown ticks when a new deadline is armed.

* docs: note PR #967 in changelog and settings credits
This commit is contained in:
cucadmuh
2026-06-03 23:37:17 +03:00
committed by GitHub
parent f3a0b3f7af
commit cd47a4b0fa
8 changed files with 147 additions and 9 deletions
+5 -4
View File
@@ -1,3 +1,4 @@
import { scheduleDeadlineMs, scheduleDelayMsFromSeconds } from '../utils/playback/playbackScheduleDelay';
import type { PlayerState } from './playerStoreTypes';
import {
clearScheduledPauseTimers,
@@ -36,9 +37,9 @@ export function createScheduleActions(set: SetState, get: GetState): Pick<
schedulePauseIn: (seconds) => {
const s = get();
if (!s.isPlaying) return;
const delayMs = Math.max(500, Math.round(Number(seconds) * 1000));
const delayMs = scheduleDelayMsFromSeconds(seconds);
const startedAt = Date.now();
const at = startedAt + delayMs;
const at = scheduleDeadlineMs(startedAt, seconds);
set({ scheduledPauseAtMs: at, scheduledPauseStartMs: startedAt });
schedulePauseTimer(delayMs, () => {
set({ scheduledPauseAtMs: null, scheduledPauseStartMs: null });
@@ -50,9 +51,9 @@ export function createScheduleActions(set: SetState, get: GetState): Pick<
const s = get();
if (s.isPlaying) return;
if (!s.currentTrack && !s.currentRadio) return;
const delayMs = Math.max(500, Math.round(Number(seconds) * 1000));
const delayMs = scheduleDelayMsFromSeconds(seconds);
const startedAt = Date.now();
const at = startedAt + delayMs;
const at = scheduleDeadlineMs(startedAt, seconds);
set({ scheduledResumeAtMs: at, scheduledResumeStartMs: startedAt });
scheduleResumeTimer(delayMs, () => {
set({ scheduledResumeAtMs: null, scheduledResumeStartMs: null });