refactor(player): E.42 — migrate playerStore re-exports to direct imports (#607)

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.
This commit is contained in:
Frank Stellmacher
2026-05-12 22:46:13 +02:00
committed by GitHub
parent e92535a5f5
commit 9fac6eb490
81 changed files with 155 additions and 236 deletions
+2 -1
View File
@@ -1,8 +1,9 @@
import { songToTrack } from '../utils/songToTrack';
import type { NavigateFunction } from 'react-router-dom';
import type { TFunction } from 'i18next';
import { getAlbum, getArtist, getSong, type SubsonicSong } from '../api/subsonic';
import { useAuthStore } from '../store/authStore';
import { songToTrack, usePlayerStore } from '../store/playerStore';
import { usePlayerStore } from '../store/playerStore';
import { findServerIdForShareUrl, type EntitySharePayloadV1 } from './shareLink';
import { showToast } from './toast';
@@ -6,6 +6,7 @@
* refactor (2026-05-12). This test pins the artist-first / random-fallback
* order, the dedup contract against existingIds, and the autoAdded flag.
*/
import type { Track } from '../store/playerStoreTypes';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
vi.mock('../api/subsonic', () => ({
@@ -26,7 +27,6 @@ import {
enrichSongsForMixRatingFilter,
getMixMinRatingsConfigFromAuth,
} from './mixRatingFilter';
import type { Track } from '../store/playerStore';
import { makeSubsonicSong } from '@/test/helpers/factories';
const seed = (overrides: Partial<Track> = {}): Track => ({
+1 -2
View File
@@ -1,3 +1,4 @@
import type { Track } from '../store/playerStoreTypes';
import { getRandomSongs, getSimilarSongs2, getTopSongs } from '../api/subsonic';
import {
enrichSongsForMixRatingFilter,
@@ -6,8 +7,6 @@ import {
} from './mixRatingFilter';
import { shuffleArray } from './shuffleArray';
import { songToTrack } from './songToTrack';
import type { Track } from '../store/playerStore';
/**
* Infinite queue source strategy (Instant Mix-like):
* 1) Prefer artist-driven candidates (Top + Similar) around the current track.
+3 -1
View File
@@ -1,3 +1,5 @@
import type { Track } from '../store/playerStoreTypes';
import { songToTrack } from '../utils/songToTrack';
import {
filterSongsToActiveLibrary,
getAlbum,
@@ -11,7 +13,7 @@ import {
import { invoke } from '@tauri-apps/api/core';
import i18n from '../i18n';
import { useAuthStore } from '../store/authStore';
import { songToTrack, usePlayerStore, type Track } from '../store/playerStore';
import { usePlayerStore } from '../store/playerStore';
import { useLuckyMixStore } from '../store/luckyMixStore';
import { isLuckyMixAvailable } from '../hooks/useLuckyMixAvailable';
import { showToast } from './toast';
+2 -1
View File
@@ -1,3 +1,4 @@
import { songToTrack } from '../utils/songToTrack';
import {
createPlaylist,
updatePlaylist,
@@ -9,7 +10,7 @@ import {
} from '../api/subsonic';
import { useAuthStore } from '../store/authStore';
import { useOrbitStore } from '../store/orbitStore';
import { usePlayerStore, songToTrack } from '../store/playerStore';
import { usePlayerStore } from '../store/playerStore';
import { encodeSharePayload, decodeOrbitSharePayloadFromText } from './shareLink';
import {
makeInitialOrbitState,
+1 -1
View File
@@ -1,6 +1,6 @@
import { getAlbum } from '../api/subsonic';
import { usePlayerStore } from '../store/playerStore';
import { songToTrack } from '../store/playerStore';
import { songToTrack } from './songToTrack';
import { useOrbitStore } from '../store/orbitStore';
function fadeOut(setVolume: (v: number) => void, from: number, durationMs: number): Promise<void> {
+3 -2
View File
@@ -1,6 +1,7 @@
import { songToTrack } from '../utils/songToTrack';
import { shuffleArray } from '../utils/shuffleArray';
import { getAlbum, getArtist } from '../api/subsonic';
import { shuffleArray, songToTrack, usePlayerStore } from '../store/playerStore';
import { usePlayerStore } from '../store/playerStore';
/**
* All tracks from the artists albums, shuffled — same idea as Artist page “shuffle play”.
*/
+2 -2
View File
@@ -1,8 +1,8 @@
import { songToTrack } from '../utils/songToTrack';
import { getAlbum, getSong } from '../api/subsonic';
import { playAlbum } from './playAlbum';
import { playArtistShuffled } from './playArtistShuffled';
import { songToTrack, usePlayerStore } from '../store/playerStore';
import { usePlayerStore } from '../store/playerStore';
/**
* `getSong` → `getAlbum` → `getArtist`: one opaque Subsonic id may refer to a track,
* album, or artist depending on the server.
+2 -1
View File
@@ -1,4 +1,5 @@
import { usePlayerStore, songToTrack } from '../store/playerStore';
import { songToTrack } from '../utils/songToTrack';
import { usePlayerStore } from '../store/playerStore';
import type { SubsonicSong } from '../api/subsonic';
function fadeOut(setVolume: (v: number) => void, from: number, durationMs: number): Promise<void> {
+1 -1
View File
@@ -4,8 +4,8 @@
* routing through the HTTP source) and the no-op detection in
* `queuesStructuralEqual` that prevents unnecessary store rewrites.
*/
import type { Track } from '../store/playerStoreTypes';
import { describe, expect, it } from 'vitest';
import type { Track } from '../store/playerStore';
import {
normalizeAnalysisTrackId,
queuesStructuralEqual,
+1 -2
View File
@@ -1,5 +1,4 @@
import type { Track } from '../store/playerStore';
import type { Track } from '../store/playerStoreTypes';
/**
* Strip the `stream:` prefix that some Rust events attach to track ids when
* they're routed through the HTTP source. Both forms identify the same track,
+1 -2
View File
@@ -5,10 +5,9 @@
* Originally lived in `playerStore.ts`; extracted in M0 of the frontend
* refactor (2026-05-12).
*/
import type { Track } from '../store/playerStoreTypes';
import { describe, expect, it } from 'vitest';
import { resolveReplayGainDb } from './resolveReplayGainDb';
import type { Track } from '../store/playerStore';
describe('resolveReplayGainDb', () => {
const t = (overrides: Partial<Track> = {}): Track => ({
id: 'x',
+1 -2
View File
@@ -1,5 +1,4 @@
import type { Track } from '../store/playerStore';
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
+1 -1
View File
@@ -5,9 +5,9 @@
* playback queue. Originally lived in `playerStore.ts`; extracted in M0 of
* the frontend refactor (2026-05-12).
*/
import type { Track } from '../store/playerStoreTypes';
import { describe, expect, it } from 'vitest';
import { songToTrack } from './songToTrack';
import type { Track } from '../store/playerStore';
import { makeSubsonicSong } from '@/test/helpers/factories';
describe('songToTrack', () => {
+1 -2
View File
@@ -1,6 +1,5 @@
import type { Track } from '../store/playerStoreTypes';
import type { SubsonicSong } from '../api/subsonic';
import type { Track } from '../store/playerStore';
export function songToTrack(song: SubsonicSong): Track {
return {
id: song.id,