diff --git a/src/renderer/components/card/card-controls.tsx b/src/renderer/components/card/card-controls.tsx index b299f589..542173fc 100644 --- a/src/renderer/components/card/card-controls.tsx +++ b/src/renderer/components/card/card-controls.tsx @@ -122,7 +122,7 @@ export const CardControls = ({ id: [itemData.id], type: itemType, }, - play: playType || playButtonBehavior, + playType: playType || playButtonBehavior, }); }; diff --git a/src/renderer/components/virtual-grid/grid-card/grid-card-controls.tsx b/src/renderer/components/virtual-grid/grid-card/grid-card-controls.tsx index 41a99161..50d505ac 100644 --- a/src/renderer/components/virtual-grid/grid-card/grid-card-controls.tsx +++ b/src/renderer/components/virtual-grid/grid-card/grid-card-controls.tsx @@ -134,7 +134,7 @@ export const GridCardControls = ({ id: [itemData.id], type: itemType, }, - play: playType || playButtonBehavior, + playType: playType || playButtonBehavior, }); }; diff --git a/src/renderer/features/albums/components/album-detail-content.tsx b/src/renderer/features/albums/components/album-detail-content.tsx index 5911d139..e64fa2e1 100644 --- a/src/renderer/features/albums/components/album-detail-content.tsx +++ b/src/renderer/features/albums/components/album-detail-content.tsx @@ -210,7 +210,7 @@ export const AlbumDetailContent = ({ tableRef }: AlbumDetailContentProps) => { const handlePlay = async (playType?: Play) => { handlePlayQueueAdd?.({ byData: detailQuery?.data?.songs, - play: playType || playButtonBehavior, + playType: playType || playButtonBehavior, }); }; @@ -218,9 +218,16 @@ export const AlbumDetailContent = ({ tableRef }: AlbumDetailContentProps) => { const handleRowDoubleClick = (e: RowDoubleClickedEvent) => { if (!e.data) return; + + const rowData: QueueSong[] = []; + e.api.forEachNode((node) => { + if (!node.data) return; + rowData.push(node.data); + }); + handlePlayQueueAdd?.({ - byData: [e.data], - play: playButtonBehavior, + byData: rowData, + playType: playButtonBehavior, }); }; diff --git a/src/renderer/features/albums/components/album-list-header-filters.tsx b/src/renderer/features/albums/components/album-list-header-filters.tsx index ed622cb7..d4681504 100644 --- a/src/renderer/features/albums/components/album-list-header-filters.tsx +++ b/src/renderer/features/albums/components/album-list-header-filters.tsx @@ -294,7 +294,7 @@ export const AlbumListHeaderFilters = ({ const handlePlayQueueAdd = usePlayQueueAdd(); - const handlePlay = async (play: Play) => { + const handlePlay = async (playType: Play) => { if (!itemCount || itemCount === 0 || !server) return; const query = { @@ -327,7 +327,7 @@ export const AlbumListHeaderFilters = ({ id: albumIds, type: LibraryItem.ALBUM, }, - play, + playType, }); }; diff --git a/src/renderer/features/albums/components/album-list-header.tsx b/src/renderer/features/albums/components/album-list-header.tsx index be95b3b5..4a20ca8b 100644 --- a/src/renderer/features/albums/components/album-list-header.tsx +++ b/src/renderer/features/albums/components/album-list-header.tsx @@ -165,7 +165,7 @@ export const AlbumListHeader = ({ const handlePlayQueueAdd = usePlayQueueAdd(); const playButtonBehavior = usePlayButtonBehavior(); - const handlePlay = async (play: Play) => { + const handlePlay = async (playType: Play) => { if (!itemCount || itemCount === 0) return; const query = { @@ -198,7 +198,7 @@ export const AlbumListHeader = ({ id: albumIds, type: LibraryItem.ALBUM, }, - play, + playType, }); }; diff --git a/src/renderer/features/albums/routes/album-detail-route.tsx b/src/renderer/features/albums/routes/album-detail-route.tsx index dc178b56..2a8805c0 100644 --- a/src/renderer/features/albums/routes/album-detail-route.tsx +++ b/src/renderer/features/albums/routes/album-detail-route.tsx @@ -30,7 +30,7 @@ const AlbumDetailRoute = () => { id: [albumId], type: LibraryItem.ALBUM, }, - play: playButtonBehavior, + playType: playButtonBehavior, }); }; diff --git a/src/renderer/features/artists/components/album-artist-detail-content.tsx b/src/renderer/features/artists/components/album-artist-detail-content.tsx index 227b97ba..ad8d1049 100644 --- a/src/renderer/features/artists/components/album-artist-detail-content.tsx +++ b/src/renderer/features/artists/components/album-artist-detail-content.tsx @@ -249,7 +249,7 @@ export const AlbumArtistDetailContent = () => { id: [albumArtistId], type: LibraryItem.ALBUM_ARTIST, }, - play: playType || playButtonBehavior, + playType: playType || playButtonBehavior, }); }; @@ -259,7 +259,7 @@ export const AlbumArtistDetailContent = () => { if (!e.data) return; handlePlayQueueAdd?.({ byData: [e.data], - play: playButtonBehavior, + playType: playButtonBehavior, }); }; diff --git a/src/renderer/features/artists/components/album-artist-detail-top-songs-list-content.tsx b/src/renderer/features/artists/components/album-artist-detail-top-songs-list-content.tsx index 987504b0..70716d08 100644 --- a/src/renderer/features/artists/components/album-artist-detail-top-songs-list-content.tsx +++ b/src/renderer/features/artists/components/album-artist-detail-top-songs-list-content.tsx @@ -36,7 +36,7 @@ export const AlbumArtistDetailTopSongsListContent = ({ if (!e.data) return; handlePlayQueueAdd?.({ byData: [e.data], - play: playButtonBehavior, + playType: playButtonBehavior, }); }; diff --git a/src/renderer/features/artists/components/album-artist-detail-top-songs-list-header.tsx b/src/renderer/features/artists/components/album-artist-detail-top-songs-list-header.tsx index a4be6c20..76d8c9bc 100644 --- a/src/renderer/features/artists/components/album-artist-detail-top-songs-list-header.tsx +++ b/src/renderer/features/artists/components/album-artist-detail-top-songs-list-header.tsx @@ -20,10 +20,10 @@ export const AlbumArtistDetailTopSongsListHeader = ({ const handlePlayQueueAdd = usePlayQueueAdd(); const playButtonBehavior = usePlayButtonBehavior(); - const handlePlay = async (play: Play) => { + const handlePlay = async (playType: Play) => { handlePlayQueueAdd?.({ byData: data, - play, + playType, }); }; diff --git a/src/renderer/features/artists/routes/album-artist-detail-route.tsx b/src/renderer/features/artists/routes/album-artist-detail-route.tsx index dcbff694..9ae0de24 100644 --- a/src/renderer/features/artists/routes/album-artist-detail-route.tsx +++ b/src/renderer/features/artists/routes/album-artist-detail-route.tsx @@ -28,7 +28,7 @@ const AlbumArtistDetailRoute = () => { id: [albumArtistId], type: LibraryItem.ALBUM_ARTIST, }, - play: playButtonBehavior, + playType: playButtonBehavior, }); }; diff --git a/src/renderer/features/context-menu/context-menu-provider.tsx b/src/renderer/features/context-menu/context-menu-provider.tsx index 29d343ca..7004eeb5 100644 --- a/src/renderer/features/context-menu/context-menu-provider.tsx +++ b/src/renderer/features/context-menu/context-menu-provider.tsx @@ -153,34 +153,34 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => { }); const handlePlay = useCallback( - (play: Play) => { + (playType: Play) => { switch (ctx.type) { case LibraryItem.ALBUM: handlePlayQueueAdd?.({ byItemType: { id: ctx.data.map((item) => item.id), type: ctx.type }, - play, + playType, }); break; case LibraryItem.ARTIST: handlePlayQueueAdd?.({ byItemType: { id: ctx.data.map((item) => item.id), type: ctx.type }, - play, + playType, }); break; case LibraryItem.ALBUM_ARTIST: handlePlayQueueAdd?.({ byItemType: { id: ctx.data.map((item) => item.id), type: ctx.type }, - play, + playType, }); break; case LibraryItem.SONG: - handlePlayQueueAdd?.({ byData: ctx.data, play }); + handlePlayQueueAdd?.({ byData: ctx.data, playType }); break; case LibraryItem.PLAYLIST: for (const item of ctx.data) { handlePlayQueueAdd?.({ byItemType: { id: [item.id], type: ctx.type }, - play, + playType, }); } diff --git a/src/renderer/features/playlists/components/playlist-detail-content.tsx b/src/renderer/features/playlists/components/playlist-detail-content.tsx index 9de71c21..51ad1ffb 100644 --- a/src/renderer/features/playlists/components/playlist-detail-content.tsx +++ b/src/renderer/features/playlists/components/playlist-detail-content.tsx @@ -154,7 +154,7 @@ export const PlaylistDetailContent = ({ tableRef }: PlaylistDetailContentProps) id: [playlistId], type: LibraryItem.PLAYLIST, }, - play: playType || playButtonBehavior, + playType: playType || playButtonBehavior, }); }; @@ -203,7 +203,7 @@ export const PlaylistDetailContent = ({ tableRef }: PlaylistDetailContentProps) if (!e.data) return; handlePlayQueueAdd?.({ byData: [e.data], - play: playButtonBehavior, + playType: playButtonBehavior, }); }; diff --git a/src/renderer/features/playlists/components/playlist-detail-song-list-content.tsx b/src/renderer/features/playlists/components/playlist-detail-song-list-content.tsx index 167fbe41..27a8288b 100644 --- a/src/renderer/features/playlists/components/playlist-detail-song-list-content.tsx +++ b/src/renderer/features/playlists/components/playlist-detail-song-list-content.tsx @@ -214,7 +214,7 @@ export const PlaylistDetailSongListContent = ({ tableRef }: PlaylistDetailConten if (!e.data) return; handlePlayQueueAdd?.({ byData: [e.data], - play: playButtonBehavior, + playType: playButtonBehavior, }); }; diff --git a/src/renderer/features/playlists/components/playlist-detail-song-list-header-filters.tsx b/src/renderer/features/playlists/components/playlist-detail-song-list-header-filters.tsx index f550dc57..f00a6739 100644 --- a/src/renderer/features/playlists/components/playlist-detail-song-list-header-filters.tsx +++ b/src/renderer/features/playlists/components/playlist-detail-song-list-header-filters.tsx @@ -234,7 +234,7 @@ export const PlaylistDetailSongListHeaderFilters = ({ const handlePlay = async (playType: Play) => { handlePlayQueueAdd?.({ byItemType: { id: [playlistId], type: LibraryItem.PLAYLIST }, - play: playType, + playType, }); }; 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 ed52843c..197d29d6 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 @@ -31,7 +31,7 @@ export const PlaylistDetailSongListHeader = ({ const handlePlay = async (playType: Play) => { handlePlayQueueAdd?.({ byItemType: { id: [playlistId], type: LibraryItem.PLAYLIST }, - play: playType, + playType, }); }; diff --git a/src/renderer/features/playlists/routes/playlist-detail-route.tsx b/src/renderer/features/playlists/routes/playlist-detail-route.tsx index c3090a01..57391050 100644 --- a/src/renderer/features/playlists/routes/playlist-detail-route.tsx +++ b/src/renderer/features/playlists/routes/playlist-detail-route.tsx @@ -35,7 +35,7 @@ const PlaylistDetailRoute = () => { id: [playlistId], type: LibraryItem.PLAYLIST, }, - play: playButtonBehavior, + playType: playButtonBehavior, }); }; diff --git a/src/renderer/features/search/components/library-command-item.tsx b/src/renderer/features/search/components/library-command-item.tsx index 7253e6ed..3a111079 100644 --- a/src/renderer/features/search/components/library-command-item.tsx +++ b/src/renderer/features/search/components/library-command-item.tsx @@ -89,14 +89,14 @@ export const LibraryCommandItem = ({ } const handlePlay = useCallback( - (e: MouseEvent, id: string, play: Play) => { + (e: MouseEvent, id: string, playType: Play) => { e.stopPropagation(); handlePlayQueueAdd?.({ byItemType: { id, type: itemType, }, - play, + playType, }); }, [handlePlayQueueAdd, itemType], diff --git a/src/renderer/features/search/components/search-content.tsx b/src/renderer/features/search/components/search-content.tsx index 41af2427..9007f208 100644 --- a/src/renderer/features/search/components/search-content.tsx +++ b/src/renderer/features/search/components/search-content.tsx @@ -110,7 +110,7 @@ export const SearchContent = ({ tableRef, getDatasource }: SearchContentProps) = case LibraryItem.SONG: handlePlayQueueAdd?.({ byData: [e.data], - play: playButtonBehavior, + playType: playButtonBehavior, }); break; } diff --git a/src/renderer/features/sidebar/components/sidebar-playlist-list.tsx b/src/renderer/features/sidebar/components/sidebar-playlist-list.tsx index c5aef80a..b527b3ed 100644 --- a/src/renderer/features/sidebar/components/sidebar-playlist-list.tsx +++ b/src/renderer/features/sidebar/components/sidebar-playlist-list.tsx @@ -119,13 +119,13 @@ export const SidebarPlaylistList = ({ data }: SidebarPlaylistListProps) => { const [debounced] = useDebouncedValue(rect, 25); const handlePlayPlaylist = useCallback( - (id: string, play: Play) => { + (id: string, playType: Play) => { handlePlayQueueAdd?.({ byItemType: { id: [id], type: LibraryItem.PLAYLIST, }, - play, + playType, }); }, [handlePlayQueueAdd], diff --git a/src/renderer/features/songs/components/song-list-content.tsx b/src/renderer/features/songs/components/song-list-content.tsx index 6ab0921f..ef438f7a 100644 --- a/src/renderer/features/songs/components/song-list-content.tsx +++ b/src/renderer/features/songs/components/song-list-content.tsx @@ -162,7 +162,7 @@ export const SongListContent = ({ itemCount, tableRef }: SongListContentProps) = if (!e.data) return; handlePlayQueueAdd?.({ byData: [e.data], - play: playButtonBehavior, + playType: playButtonBehavior, }); }; diff --git a/src/renderer/features/songs/components/song-list-header-filters.tsx b/src/renderer/features/songs/components/song-list-header-filters.tsx index f8fecd9c..68d9f2fa 100644 --- a/src/renderer/features/songs/components/song-list-header-filters.tsx +++ b/src/renderer/features/songs/components/song-list-header-filters.tsx @@ -261,7 +261,7 @@ export const SongListHeaderFilters = ({ handleFilterChange(filter); }; - const handlePlay = async (play: Play) => { + const handlePlay = async (playType: Play) => { if (!itemCount || itemCount === 0) return; const query: SongListQuery = { startIndex: 0, ...filter, ...customFilters }; @@ -270,7 +270,7 @@ export const SongListHeaderFilters = ({ id: query, type: LibraryItem.SONG, }, - play, + playType, }); }; diff --git a/src/renderer/features/songs/components/song-list-header.tsx b/src/renderer/features/songs/components/song-list-header.tsx index a6be60d6..0747ee9e 100644 --- a/src/renderer/features/songs/components/song-list-header.tsx +++ b/src/renderer/features/songs/components/song-list-header.tsx @@ -94,7 +94,7 @@ export const SongListHeader = ({ const playButtonBehavior = usePlayButtonBehavior(); - const handlePlay = async (play: Play) => { + const handlePlay = async (playType: Play) => { if (!itemCount || itemCount === 0) return; const query: SongListQuery = { startIndex: 0, ...filter, ...customFilters }; @@ -103,7 +103,7 @@ export const SongListHeader = ({ id: query, type: LibraryItem.SONG, }, - play, + playType, }); }; diff --git a/src/renderer/store/player.store.ts b/src/renderer/store/player.store.ts index 0a0f932e..bd544963 100644 --- a/src/renderer/store/player.store.ts +++ b/src/renderer/store/player.store.ts @@ -56,7 +56,7 @@ export interface QueueData { export interface PlayerSlice extends PlayerState { actions: { - addToQueue: (songs: QueueSong[], type: Play) => PlayerData; + addToQueue: (args: { initialIndex: number; playType: Play; songs: QueueSong[] }) => PlayerData; autoNext: () => PlayerData; checkIsFirstTrack: () => boolean; checkIsLastTrack: () => boolean; @@ -95,7 +95,8 @@ export const usePlayerStore = create()( devtools( immer((set, get) => ({ actions: { - addToQueue: (songs, type) => { + addToQueue: (args) => { + const { playType, songs } = args; const { shuffledIndex } = get().current; const shuffledQueue = get().queue.shuffled; const queueSongs = map(songs, (song) => ({ @@ -103,7 +104,7 @@ export const usePlayerStore = create()( uniqueId: nanoid(), })); - if (type === Play.NOW) { + if (playType === Play.NOW) { if (get().shuffle === PlayerShuffle.TRACK) { const shuffledSongs = shuffle(queueSongs); const foundIndex = queueSongs.findIndex( @@ -131,7 +132,7 @@ export const usePlayerStore = create()( state.current.song = queueSongs[0]; }); } - } else if (type === Play.LAST) { + } else if (playType === Play.LAST) { // Shuffle the queue after the current track const shuffledQueueWithNewSongs = get().shuffle === PlayerShuffle.TRACK @@ -148,7 +149,7 @@ export const usePlayerStore = create()( state.queue.default = [...get().queue.default, ...queueSongs]; state.queue.shuffled = shuffledQueueWithNewSongs; }); - } else if (type === Play.NEXT) { + } else if (playType === Play.NEXT) { const queue = get().queue.default; const currentIndex = get().current.index; diff --git a/src/renderer/types.ts b/src/renderer/types.ts index 8fa7deab..2323869e 100644 --- a/src/renderer/types.ts +++ b/src/renderer/types.ts @@ -154,7 +154,8 @@ export type PlayQueueAddOptions = { id: string[] | any; type: LibraryItem; }; - play: Play; + initialIndex?: number; + playType: Play; }; export type GridCardData = {