Files
Psychotoxical-psysonic/src/store/infiniteQueueState.ts
T
Frank Stellmacher 14bdcde33f refactor(player): E.24 — extract radio session + infinite-queue guards (#588)
Cluster of four small mutables in two modules:

  - `src/store/radioSessionState.ts` — `radioFetching` (concurrent
    fetch guard) + `currentRadioArtistId` (seed artist that survives
    track advances) + `radioSessionSeenIds` (dedupe set including
    HISTORY_KEEP-evicted entries, fixes issue #500).
  - `src/store/infiniteQueueState.ts` — `infiniteQueueFetching`
    concurrent fetch guard.

Sed-driven bulk rewrite for the >35 direct-access sites. The four
`= new Set()` resets become `clearRadioSessionSeenIds()` calls and
the `setRadioArtistId` / `enqueueRadio` actions read through
`getCurrentRadioArtistId()` instead of touching the mutable directly.

15 focused tests across the two modules.

playerStore 2867 → 2865 LOC.
2026-05-12 17:26:15 +02:00

23 lines
689 B
TypeScript

/**
* Concurrent-fetch guard for the infinite-queue feature. Stops a second
* `buildInfiniteQueueCandidates` request from running while the first
* is still pending — without it, switching tracks quickly while the
* infinite tail is loading would race two enqueue actions and the
* second would clobber the first's results.
*/
let infiniteQueueFetching = false;
export function isInfiniteQueueFetching(): boolean {
return infiniteQueueFetching;
}
export function setInfiniteQueueFetching(value: boolean): void {
infiniteQueueFetching = value;
}
/** Test-only: reset the guard. */
export function _resetInfiniteQueueStateForTest(): void {
infiniteQueueFetching = false;
}