mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +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.
36 lines
938 B
TypeScript
36 lines
938 B
TypeScript
import { songToTrack } from '../utils/songToTrack';
|
|
import { getAlbum, getSong } from '../api/subsonic';
|
|
import { playAlbum } from './playAlbum';
|
|
import { playArtistShuffled } from './playArtistShuffled';
|
|
import { usePlayerStore } from '../store/playerStore';
|
|
/**
|
|
* `getSong` → `getAlbum` → `getArtist`: one opaque Subsonic id may refer to a track,
|
|
* album, or artist depending on the server.
|
|
*/
|
|
export async function playByOpaqueId(id: string): Promise<void> {
|
|
const trimmed = id.trim();
|
|
if (!trimmed) return;
|
|
|
|
const song = await getSong(trimmed);
|
|
if (song) {
|
|
usePlayerStore.getState().playTrack(songToTrack(song));
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const { songs } = await getAlbum(trimmed);
|
|
if (songs.length > 0) {
|
|
await playAlbum(trimmed);
|
|
return;
|
|
}
|
|
} catch {
|
|
/* not an album */
|
|
}
|
|
|
|
try {
|
|
await playArtistShuffled(trimmed);
|
|
} catch {
|
|
throw new Error('play_by_id_not_found');
|
|
}
|
|
}
|