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:
Mistral Vibe
2026-04-08 20:58:16 +02:00
parent 7508d78a86
commit 25dca3c788
4 changed files with 19 additions and 39 deletions

View File

@@ -86,7 +86,7 @@ class AudioService {
}
await this.wavesurfer.play();
if (songId && bandId) {
usePlayerStore.getState().setCurrentPlayingSong(songId, bandId);
usePlayerStore.getState().setCurrentSong(songId, bandId);
}
}
@@ -116,19 +116,10 @@ class AudioService {
return this.isReady && !!this.wavesurfer;
}
// Aliases kept for callers until Phase 3 cleans them up
public isReadyForPlayback(): boolean {
return this.isWaveformReady();
}
public canAttemptPlayback(): boolean {
return this.isWaveformReady();
}
public cleanup(): void {
this.destroyWaveSurfer();
const store = usePlayerStore.getState();
store.setCurrentPlayingSong(null, null);
store.setCurrentSong(null, null);
store.batchUpdate({ isPlaying: false, currentTime: 0 });
}