diff --git a/src/components/library/GenreList.tsx b/src/components/library/GenreList.tsx index e024f87..49f6ae0 100644 --- a/src/components/library/GenreList.tsx +++ b/src/components/library/GenreList.tsx @@ -76,9 +76,6 @@ const GenreList = () => { listType="genre" virtualized disabledContextMenuOptions={[ - 'play', - 'addToQueueNext', - 'addToQueueLast', 'moveSelectedTo', 'removeSelected', 'addToPlaylist', diff --git a/src/components/shared/ContextMenu.tsx b/src/components/shared/ContextMenu.tsx index 256939d..ade4225 100644 --- a/src/components/shared/ContextMenu.tsx +++ b/src/components/shared/ContextMenu.tsx @@ -234,6 +234,36 @@ export const GlobalContextMenu = () => { dispatch(setStatus('PAUSED')); } + notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'play' })); + } else if (misc.contextMenu.type === 'genre') { + for (let i = 0; i < multiSelect.selected.length; i += 1) { + promises.push( + apiController({ + serverType: config.serverType, + endpoint: 'getSongsByGenre', + args: { + type: 'byGenre', + genre: multiSelect.selected[i].title, + musicFolderId: musicFolder, + size: 100, + offset: 0, + recursive: true, + }, + }) + ); + } + + const res = await Promise.all(promises); + const songs = filterPlayQueue(config.playback.filters, _.flatten(_.map(res, 'data'))); + if (songs.entries.length > 0) { + dispatch(setPlayQueue({ entries: songs.entries })); + dispatch(setStatus('PLAYING')); + dispatch(fixPlayer2Index()); + } else { + dispatch(clearPlayQueue()); + dispatch(setStatus('PAUSED')); + } + notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'play' })); } }; @@ -329,6 +359,33 @@ export const GlobalContextMenu = () => { dispatch(fixPlayer2Index()); } + notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'add' })); + } else if (misc.contextMenu.type === 'genre') { + for (let i = 0; i < multiSelect.selected.length; i += 1) { + promises.push( + apiController({ + serverType: config.serverType, + endpoint: 'getSongsByGenre', + args: { + type: 'byGenre', + genre: multiSelect.selected[i].title, + musicFolderId: musicFolder, + size: 100, + offset: 0, + recursive: true, + }, + }) + ); + } + + const res = await Promise.all(promises); + const songs = filterPlayQueue(config.playback.filters, _.flatten(_.map(res, 'data'))); + + if (songs.entries.length > 0) { + dispatch(appendPlayQueue({ entries: songs.entries, type })); + dispatch(fixPlayer2Index()); + } + notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'add' })); } };