mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
ddead24678
Two small file-private helpers move into dedicated modules under src/store/: - `waveformRefreshGen.ts` — the per-track generation counter that guards against applying a stale waveform read after the cache was invalidated. Exposes `bumpWaveformRefreshGen` (existing) + `getWaveformRefreshGen` (new accessor that replaces the two direct reads at `refreshWaveformForTrack`). - `hotCacheTouch.ts` — `touchHotCacheOnPlayback` with its empty-id guards, called from every `audio_play` entry point. Both file-private; no caller-side changes outside playerStore's own imports. 8 focused tests pin the generation-increment + isolation contract and the touch helper's empty-id guards. playerStore 3302 → 3291 LOC.
15 lines
684 B
TypeScript
15 lines
684 B
TypeScript
import { useHotCacheStore } from './hotCacheStore';
|
|
|
|
/**
|
|
* Mark a track as recently played for the hot-cache LRU. Called from every
|
|
* `audio_play` entry point — cold start, gapless switch, queue rewrite,
|
|
* radio next — so the hot cache promotes frequently-played tracks even when
|
|
* playback bounced through different code paths. The empty-id guards keep
|
|
* dev-time crashes (e.g. unauthenticated state, server still resolving)
|
|
* from surfacing as cache writes against a meaningless key.
|
|
*/
|
|
export function touchHotCacheOnPlayback(trackId: string, serverId: string): void {
|
|
if (!trackId || !serverId) return;
|
|
useHotCacheStore.getState().touchPlayed(trackId, serverId);
|
|
}
|