refactor(audio): Phase 4 — unify song tracking, remove compat aliases
playerStore: remove currentPlayingSongId/currentPlayingBandId/setCurrentPlayingSong. Single pair (currentSongId/currentBandId) now set exclusively when play() is called, not when the page opens. This means MiniPlayer and sidebar links only appear after audio has been started — correct UX for a "now playing" widget. audioService: play() calls setCurrentSong instead of setCurrentPlayingSong; cleanup() clears it. Remove isReadyForPlayback() and canAttemptPlayback() aliases — all callers now use isWaveformReady() directly. useWaveform: remove setCurrentSong call from init (store updated by play() now); restore-playback snapshot reads currentSongId/currentBandId. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -164,19 +164,19 @@ describe('AudioService', () => {
|
||||
expect(mockWs.play).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('updates currentPlayingSongId/BandId in the store', async () => {
|
||||
it('updates currentSongId/BandId in the store', async () => {
|
||||
await initService(service);
|
||||
await service.play('song-1', 'band-1');
|
||||
const state = usePlayerStore.getState();
|
||||
expect(state.currentPlayingSongId).toBe('song-1');
|
||||
expect(state.currentPlayingBandId).toBe('band-1');
|
||||
expect(state.currentSongId).toBe('song-1');
|
||||
expect(state.currentBandId).toBe('band-1');
|
||||
});
|
||||
|
||||
it('does not update store ids when called without ids', async () => {
|
||||
await initService(service);
|
||||
await service.play();
|
||||
const state = usePlayerStore.getState();
|
||||
expect(state.currentPlayingSongId).toBeNull();
|
||||
expect(state.currentSongId).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user