mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 15:25:46 +00:00
cb1a110afb
Relocate the playback/queue/transport/audio-output engine out of the type-first
store/ + utils/playback/ + utils/audio/ dirs into a cohesive src/features/playback/,
structure-preserving:
store/<x> -> features/playback/store/<x>
store/audioListenerSetup/<x> -> features/playback/store/audioListenerSetup/<x>
utils/playback/<x> -> features/playback/utils/playback/<x>
utils/audio/<x> -> features/playback/utils/audio/<x>
184 files moved (107 source + 77 tests), 365 consumers rewritten. Pure move — no
behavior change, no state-split (the playerStore state-split stays a separate M5
question). Enabled by this session's decouple seams (artist/offline/orbit/auth →
core registries), so the engine carries no inbound core->feature inversion: store/
now holds only the 50 cross-cutting global stores (auth family, the seams, library
index, UI/settings stores).
KEPT OUT of the move (would re-create global->engine edges): the 3 pure config
helpers utils/audio/{loudnessPreAnalysisSlider,hiResCrossfadeResample} +
utils/playback/autodjOverlapCap (authStore + settings UI read them — they stay in
utils/). Ambiguous view-state stores (eqStore, queueToolbarStore,
playerBarLayoutStore) stay global (no engine imports).
Consumers use DEEP paths (@/features/playback/...), no barrel — matches the lib/
approach and avoids barrel-mock-collapse across the 140 usePlayerStore consumers.
Two tolerated type-only core->feature edges remain (localPlaybackStore->QueueItemRef,
localPlaybackMigration->HotCacheEntry, both erased).
tsc 0, lint 0, full suite 319/2353 green, iron-rule clean (no runtime store->feature
import). Behavior-touching only via the prerequisite bridge seam (already QA-flagged);
the move itself is pure.
67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
/**
|
|
* Per-session bookkeeping for the radio-feature (auto-mix tail of
|
|
* tracks based on a seed artist):
|
|
*
|
|
* - **radioFetching** — concurrent-fetch guard. Stops two parallel
|
|
* `getSimilarSongs` / `getTopSongs` requests from racing each other
|
|
* when both `next()` and the proactive top-up path fire close
|
|
* together.
|
|
*
|
|
* - **currentRadioArtistId** — the seed artist that started the
|
|
* current radio session. Survives track advances so subsequent
|
|
* top-ups can resolve a new tail even when the now-playing track
|
|
* has no `artistId` of its own.
|
|
*
|
|
* - **radioSessionSeenIds** — every id the current radio session has
|
|
* enqueued so far, *including* entries that were trimmed off the
|
|
* front of the queue once it grew past `HISTORY_KEEP`. Without this
|
|
* set, the queue's own id-set wasn't enough to dedupe: a song
|
|
* played 8 tracks ago is gone from the queue and the next
|
|
* Last.fm / topSongs response could re-add it (issue #500). Reset
|
|
* on `setRadioArtistId(other)` and on `clearQueue()`.
|
|
*/
|
|
|
|
let radioFetching = false;
|
|
let currentRadioArtistId: string | null = null;
|
|
let radioSessionSeenIds = new Set<string>();
|
|
|
|
export function isRadioFetching(): boolean {
|
|
return radioFetching;
|
|
}
|
|
|
|
export function setRadioFetching(value: boolean): void {
|
|
radioFetching = value;
|
|
}
|
|
|
|
export function getCurrentRadioArtistId(): string | null {
|
|
return currentRadioArtistId;
|
|
}
|
|
|
|
export function setCurrentRadioArtistId(id: string | null): void {
|
|
currentRadioArtistId = id;
|
|
}
|
|
|
|
export function hasRadioSessionSeen(id: string): boolean {
|
|
return radioSessionSeenIds.has(id);
|
|
}
|
|
|
|
export function addRadioSessionSeen(id: string): void {
|
|
radioSessionSeenIds.add(id);
|
|
}
|
|
|
|
export function deleteRadioSessionSeen(id: string): void {
|
|
radioSessionSeenIds.delete(id);
|
|
}
|
|
|
|
/** Drop every id the current session has remembered — call when the seed artist changes or the queue is cleared. */
|
|
export function clearRadioSessionSeenIds(): void {
|
|
radioSessionSeenIds = new Set();
|
|
}
|
|
|
|
/** Test-only: reset all three pieces of state. */
|
|
export function _resetRadioSessionStateForTest(): void {
|
|
radioFetching = false;
|
|
currentRadioArtistId = null;
|
|
radioSessionSeenIds = new Set();
|
|
}
|