diff --git a/src/renderer/features/playlists/components/playlist-detail-song-list-header.tsx b/src/renderer/features/playlists/components/playlist-detail-song-list-header.tsx index a8e72fe2..5d7d4087 100644 --- a/src/renderer/features/playlists/components/playlist-detail-song-list-header.tsx +++ b/src/renderer/features/playlists/components/playlist-detail-song-list-header.tsx @@ -20,6 +20,8 @@ import { Text, TextTitle, } from '/@/renderer/components'; +import { usePlayQueueAdd } from '/@/renderer/features/player'; +import { usePlaylistDetail } from '/@/renderer/features/playlists/queries/playlist-detail-query'; import { useContainerQuery } from '/@/renderer/hooks'; import { useCurrentServer, @@ -30,7 +32,7 @@ import { useSetPlaylistDetailFilters, useSetPlaylistStore, } from '/@/renderer/store'; -import { ListDisplayType, TableColumn } from '/@/renderer/types'; +import { LibraryItem, ListDisplayType, Play, TableColumn } from '/@/renderer/types'; const FILTERS = { jellyfin: [ @@ -93,6 +95,9 @@ export const PlaylistDetailSongListHeader = ({ tableRef }: PlaylistDetailHeaderP sortOrder: page?.table.id[playlistId]?.filter?.sortOrder || SortOrder.ASC, }; + const detailQuery = usePlaylistDetail({ id: playlistId }); + const handlePlayQueueAdd = usePlayQueueAdd(); + const cq = useContainerQuery(); const setPagination = useSetPlaylistTablePagination(); @@ -217,6 +222,15 @@ export const PlaylistDetailSongListHeader = ({ tableRef }: PlaylistDetailHeaderP } }; + const handlePlay = async (playType: Play) => { + handlePlayQueueAdd?.({ + byItemType: { id: [playlistId], type: LibraryItem.PLAYLIST }, + play: playType, + }); + }; + + if (detailQuery.isLoading) return null; + return ( @@ -238,7 +252,7 @@ export const PlaylistDetailSongListHeader = ({ tableRef }: PlaylistDetailHeaderP fw="bold" order={3} > - Playlist + {detailQuery?.data?.name} @@ -350,44 +364,23 @@ export const PlaylistDetailSongListHeader = ({ tableRef }: PlaylistDetailHeaderP - Play - Add to queue (next) - Add to queue (last) - Add to playlist + handlePlay(Play.NOW)}>Play + handlePlay(Play.NEXT)} + > + Add to queue (last) + + handlePlay(Play.LAST)} + > + Add to queue (next) + - {/* */} - {/* - - - Playlist - - - - {detailQuery?.data?.name} - - - - - */} - {/* */} ); };