fixed compile errors

This commit is contained in:
Srihari Chandana
2020-04-29 21:25:43 -04:00
committed by Deluan Quintão
parent e6d4cfba96
commit eb7d2dcaa1
2 changed files with 29 additions and 24 deletions
+12 -7
View File
@@ -3,12 +3,12 @@ import IconButton from '@material-ui/core/IconButton'
import Menu from '@material-ui/core/Menu'
import MenuItem from '@material-ui/core/MenuItem'
import MoreVertIcon from '@material-ui/icons/MoreVert'
import { useDataProvider, useTranslate } from 'react-admin';
import { useDataProvider, useTranslate } from 'react-admin'
import { useDispatch } from 'react-redux'
import { playAlbum, shuffleAlbum } from '../audioplayer'
const AlbumContextMenu = (props) => {
const dataProvider = useDataProvider();
const dataProvider = useDataProvider()
const dispatch = useDispatch()
const translate = useTranslate()
const [anchorEl, setAnchorEl] = useState(null)
@@ -16,11 +16,11 @@ const AlbumContextMenu = (props) => {
const options = {
play: {
label: translate('resources.album.actions.playAll'),
action: (data, id) => (playAlbum(id, data))
action: (data, id) => playAlbum(id, data),
},
shuffle: {
label: translate('resources.album.actions.shuffle'),
action: (data) => (shuffleAlbum(data))
action: (data) => shuffleAlbum(data),
},
}
@@ -38,12 +38,17 @@ const AlbumContextMenu = (props) => {
e.preventDefault()
setAnchorEl(null)
const key = e.target.getAttribute('value')
dataProvider.getList('albumSong', {
dataProvider
.getList('albumSong', {
pagination: { page: 0, perPage: 1000 },
sort: { field: 'trackNumber', order: 'ASC' },
filter: { album_id: props.id },
}).then((response) => {
const adata = (response.data).reduce((acc, cur) => ({ ...acc, [cur.id]: cur }), {})
})
.then((response) => {
const adata = response.data.reduce(
(acc, cur) => ({ ...acc, [cur.id]: cur }),
{}
)
dispatch(options[key].action(adata, response.data[0].id))
})
}
+2 -2
View File
@@ -6,7 +6,7 @@ import { Link } from 'react-router-dom'
import { linkToRecord, Loading } from 'react-admin'
import subsonic from '../subsonic'
import { ArtistLinkField } from './ArtistLinkField'
import GridMenu from './GridMenu.js'
import AlbumContextMenu from './AlbumContextMenu.js'
const useStyles = makeStyles((theme) => ({
root: {
@@ -81,7 +81,7 @@ const LoadedAlbumGrid = ({ ids, data, basePath, width }) => {
</ArtistLinkField>
</div>
}
actionIcon={<GridMenu id={id} />}
actionIcon={<AlbumContextMenu id={id} />}
/>
</GridListTile>
))}