Add "Play Next" action (finally)

This commit is contained in:
Deluan
2020-09-21 20:10:52 -04:00
parent aa133e6b00
commit 7305e3aa17
14 changed files with 130 additions and 23 deletions
+11 -9
View File
@@ -8,9 +8,9 @@ import {
} from 'react-admin'
import { useDispatch } from 'react-redux'
import { addTracks } from '../audioplayer'
import AddToQueueIcon from '@material-ui/icons/AddToQueue'
import { RiPlayListAddFill } from 'react-icons/ri'
const AddToQueueButton = ({ resource, selectedIds }) => {
const AddToQueueButton = ({ resource, selectedIds, action, label, icon }) => {
const dispatch = useDispatch()
const translate = useTranslate()
const dataProvider = useDataProvider()
@@ -27,7 +27,7 @@ const AddToQueueButton = ({ resource, selectedIds }) => {
{}
)
// Add the tracks to the queue in the selection order
dispatch(addTracks(tracks, selectedIds))
dispatch(action(tracks, selectedIds))
})
.catch(() => {
notify('ra.page.error', 'warning')
@@ -36,14 +36,16 @@ const AddToQueueButton = ({ resource, selectedIds }) => {
}
return (
<Button
color="secondary"
onClick={addToQueue}
label={translate('resources.song.actions.addToQueue')}
>
<AddToQueueIcon />
<Button color="secondary" onClick={addToQueue} label={translate(label)}>
{icon}
</Button>
)
}
AddToQueueButton.defaultProps = {
action: addTracks,
label: 'resources.song.actions.addToQueue',
icon: <RiPlayListAddFill />,
}
export default AddToQueueButton