Browse Source

Add context menu play for genre list

master
jeffvli 3 years ago
committed by Jeff
parent
commit
4bf0dbf90b
  1. 3
      src/components/library/GenreList.tsx
  2. 57
      src/components/shared/ContextMenu.tsx

3
src/components/library/GenreList.tsx

@ -76,9 +76,6 @@ const GenreList = () => {
listType="genre" listType="genre"
virtualized virtualized
disabledContextMenuOptions={[ disabledContextMenuOptions={[
'play',
'addToQueueNext',
'addToQueueLast',
'moveSelectedTo', 'moveSelectedTo',
'removeSelected', 'removeSelected',
'addToPlaylist', 'addToPlaylist',

57
src/components/shared/ContextMenu.tsx

@ -234,6 +234,36 @@ export const GlobalContextMenu = () => {
dispatch(setStatus('PAUSED')); 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' })); notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'play' }));
} }
}; };
@ -329,6 +359,33 @@ export const GlobalContextMenu = () => {
dispatch(fixPlayer2Index()); 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' })); notifyToast('info', getPlayedSongsNotification({ ...songs.count, type: 'add' }));
} }
}; };

Loading…
Cancel
Save