mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05:46 +00:00
fix: context menu Play Now playback and resize behaviour (#1174)
* fix(playlist): play the playlist from the context menu Play Now action The Playlists-page context menu 'Play Now' only navigated to the playlist detail page instead of starting playback. It now loads the playlist's songs and plays them via the shared playPlaylistAll action (same path as the detail page 'Play All' button), with a guard against load failures. * fix(ui): close the context menu on window resize The context menu is absolutely positioned at fixed coordinates, so resizing the window left it stranded and drifting off-screen. Whether a resize closed it was inconsistent across setups (it stayed open on some Windows and Linux environments). Always close it on resize so the behaviour is the same everywhere. * docs(changelog): context menu Play Now and resize fixes (#1174) * docs(changelog): credit the reporter for the context menu fixes
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { getPlaylist } from '../../api/subsonicPlaylists';
|
||||
import { songToTrack } from '../playback/songToTrack';
|
||||
import { usePlayerStore } from '../../store/playerStore';
|
||||
import { usePlaylistStore } from '../../store/playlistStore';
|
||||
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();
|
||||
const { touchPlaylist } = usePlaylistStore.getState();
|
||||
playPlaylistAll({ songsLength: tracks.length, id, tracks, touchPlaylist, playTrack, enqueue });
|
||||
}
|
||||
Reference in New Issue
Block a user