mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 14:35:41 +00:00
9fac6eb490
Migrates ~74 call sites away from the playerStore re-export shims that were kept during M0–E.41 to avoid touching 30+ imports per PR. Now that the bigger refactor work is done, each helper goes back to its real home: - `initAudioListeners`, `installQueueUndoHotkey`, `flushPlayQueuePosition` → from their own store modules - `getPlaybackProgressSnapshot`, `subscribePlaybackProgress`, `PlaybackProgressSnapshot` → from `playbackProgress` - `resolveReplayGainDb`, `shuffleArray`, `songToTrack` → from `utils/*` - `_resetQueueUndoStacksForTest`, `consumePendingQueueListScrollTop`, `registerQueueListScrollTopReader` → from `queueUndo` - `PlayerState`, `Track` types → from `playerStoreTypes` Drops the corresponding 13 re-export stubs from `playerStore.ts` and the now-unused imports. Also drops dead section banners + per-wrapper comments above one-line action delegates. Trims one stale "(separate PR)" note in `transportLightActions.ts` since that follow-up landed in E.39. `playerStore.ts`: 180 → 112 LOC (−68). Down from Phase E's starting 3732 LOC. `bootstrap.test.ts` mock target updated from `../store/playerStore` to `../store/queueUndoHotkey` to keep the spy reachable after the import change.
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import type { Track } from '../store/playerStoreTypes';
|
|
/**
|
|
* Resolve the ReplayGain dB value for a track based on the configured mode.
|
|
* In 'auto' mode, picks album-gain when an adjacent queue neighbour shares the
|
|
* same albumId (i.e. the track is being played as part of an album), otherwise
|
|
* track-gain. Falls back to track-gain when album-gain is missing.
|
|
*/
|
|
export function resolveReplayGainDb(
|
|
track: Track,
|
|
prevTrack: Track | null | undefined,
|
|
nextTrack: Track | null | undefined,
|
|
enabled: boolean,
|
|
mode: 'track' | 'album' | 'auto',
|
|
): number | null {
|
|
if (!enabled) return null;
|
|
let useAlbum: boolean;
|
|
if (mode === 'album') {
|
|
useAlbum = true;
|
|
} else if (mode === 'track') {
|
|
useAlbum = false;
|
|
} else {
|
|
const albumId = track.albumId;
|
|
useAlbum = !!albumId && (
|
|
prevTrack?.albumId === albumId || nextTrack?.albumId === albumId
|
|
);
|
|
}
|
|
const value = useAlbum
|
|
? (track.replayGainAlbumDb ?? track.replayGainTrackDb)
|
|
: track.replayGainTrackDb;
|
|
return value ?? null;
|
|
}
|