From 0833d87f94e48cbffc7c8fa510e9f5131b3363e4 Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 5 May 2020 12:20:41 -0400 Subject: [PATCH] Add "Play Later" action to AlbumContextMenu --- ui/src/album/AlbumContextMenu.js | 6 +++++- ui/src/song/AddToQueueButton.js | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/src/album/AlbumContextMenu.js b/ui/src/album/AlbumContextMenu.js index 3e084eff6..657f9eb71 100644 --- a/ui/src/album/AlbumContextMenu.js +++ b/ui/src/album/AlbumContextMenu.js @@ -6,7 +6,7 @@ import MoreVertIcon from '@material-ui/icons/MoreVert' import { makeStyles } from '@material-ui/core/styles' import { useDataProvider, useNotify, useTranslate } from 'react-admin' import { useDispatch } from 'react-redux' -import { playAlbum, shuffleAlbum } from '../audioplayer' +import { addTracks, playAlbum, shuffleAlbum } from '../audioplayer' const useStyles = makeStyles({ icon: { @@ -27,6 +27,10 @@ const AlbumContextMenu = ({ record, color }) => { label: translate('resources.album.actions.playAll'), action: (data, id) => playAlbum(id, data), }, + addToQueue: { + label: translate('resources.album.actions.addToQueue'), + action: (data) => addTracks(Object.values(data)), + }, shuffle: { label: translate('resources.album.actions.shuffle'), action: (data) => shuffleAlbum(data), diff --git a/ui/src/song/AddToQueueButton.js b/ui/src/song/AddToQueueButton.js index b3b58a2ce..0b0456167 100644 --- a/ui/src/song/AddToQueueButton.js +++ b/ui/src/song/AddToQueueButton.js @@ -22,10 +22,10 @@ const AddToQueueButton = ({ selectedIds }) => { .getMany('song', { ids: selectedIds }) .then((response) => { // Add tracks to a map for easy lookup by ID, needed for the next step - const tracks = response.data.reduce((acc, cur) => { - acc[cur.id] = cur - return acc - }, {}) + const tracks = response.data.reduce( + (acc, cur) => ({ ...acc, [cur.id]: cur }), + {} + ) // Add the tracks to the queue in the selection order dispatch(addTracks(selectedIds.map((id) => tracks[id]))) })