mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05:46 +00:00
6d4d82d6a3
* fix(playlist): stop the detail page reloading on Play/Shuffle/Enqueue * docs(changelog): playlist play no longer reloads the page
20 lines
927 B
TypeScript
20 lines
927 B
TypeScript
import { getPlaylist } from '../../api/subsonicPlaylists';
|
|
import { songToTrack } from '../playback/songToTrack';
|
|
import { usePlayerStore } from '../../store/playerStore';
|
|
import { playPlaylistAll } from './playlistBulkPlayActions';
|
|
|
|
/**
|
|
* Load a playlist's songs and start playback immediately ("Play Now").
|
|
*
|
|
* Used where only the playlist metadata is on hand — the playlist context menu
|
|
* on the Playlists overview — so the tracks have to be fetched first. Once
|
|
* loaded it defers to {@link playPlaylistAll}, the same action the playlist
|
|
* detail "Play All" button uses, so playback behaviour stays in one place.
|
|
*/
|
|
export async function playPlaylistById(id: string): Promise<void> {
|
|
const { songs } = await getPlaylist(id);
|
|
const tracks = songs.map(songToTrack);
|
|
const { playTrack, enqueue } = usePlayerStore.getState();
|
|
playPlaylistAll({ songsLength: tracks.length, id, tracks, playTrack, enqueue });
|
|
}
|