mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-26 16:32:18 +03:00
Add "Play Later" action to AlbumContextMenu
This commit is contained in:
parent
23836d7c3c
commit
0833d87f94
@ -6,7 +6,7 @@ import MoreVertIcon from '@material-ui/icons/MoreVert'
|
|||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import { useDataProvider, useNotify, useTranslate } from 'react-admin'
|
import { useDataProvider, useNotify, useTranslate } from 'react-admin'
|
||||||
import { useDispatch } from 'react-redux'
|
import { useDispatch } from 'react-redux'
|
||||||
import { playAlbum, shuffleAlbum } from '../audioplayer'
|
import { addTracks, playAlbum, shuffleAlbum } from '../audioplayer'
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
icon: {
|
icon: {
|
||||||
@ -27,6 +27,10 @@ const AlbumContextMenu = ({ record, color }) => {
|
|||||||
label: translate('resources.album.actions.playAll'),
|
label: translate('resources.album.actions.playAll'),
|
||||||
action: (data, id) => playAlbum(id, data),
|
action: (data, id) => playAlbum(id, data),
|
||||||
},
|
},
|
||||||
|
addToQueue: {
|
||||||
|
label: translate('resources.album.actions.addToQueue'),
|
||||||
|
action: (data) => addTracks(Object.values(data)),
|
||||||
|
},
|
||||||
shuffle: {
|
shuffle: {
|
||||||
label: translate('resources.album.actions.shuffle'),
|
label: translate('resources.album.actions.shuffle'),
|
||||||
action: (data) => shuffleAlbum(data),
|
action: (data) => shuffleAlbum(data),
|
||||||
|
@ -22,10 +22,10 @@ const AddToQueueButton = ({ selectedIds }) => {
|
|||||||
.getMany('song', { ids: selectedIds })
|
.getMany('song', { ids: selectedIds })
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// Add tracks to a map for easy lookup by ID, needed for the next step
|
// Add tracks to a map for easy lookup by ID, needed for the next step
|
||||||
const tracks = response.data.reduce((acc, cur) => {
|
const tracks = response.data.reduce(
|
||||||
acc[cur.id] = cur
|
(acc, cur) => ({ ...acc, [cur.id]: cur }),
|
||||||
return acc
|
{}
|
||||||
}, {})
|
)
|
||||||
// Add the tracks to the queue in the selection order
|
// Add the tracks to the queue in the selection order
|
||||||
dispatch(addTracks(selectedIds.map((id) => tracks[id])))
|
dispatch(addTracks(selectedIds.map((id) => tracks[id])))
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user