mirror of
https://github.com/navidrome/navidrome.git
synced 2025-08-10 00:52:20 +00:00
43 lines
915 B
JavaScript
43 lines
915 B
JavaScript
import React, { useCallback } from 'react'
|
|
import { useDispatch } from 'react-redux'
|
|
import { playAlbum } from '../audioplayer'
|
|
import { Loading, useGetList} from 'react-admin'
|
|
import IconButton from '@material-ui/core/IconButton'
|
|
import PlayIcon from '@material-ui/icons/PlayCircleFilled'
|
|
|
|
const GridButton = (props) => {
|
|
const dispatch = useDispatch()
|
|
const { ids, data, loading, error } = useGetList(
|
|
'albumSong',
|
|
{ },
|
|
{ field: 'trackNumber', order: 'ASC' },
|
|
{ album_id: props.id},
|
|
)
|
|
|
|
if (loading) {
|
|
return (
|
|
<IconButton>
|
|
<PlayIcon/>
|
|
</IconButton>
|
|
)
|
|
}
|
|
|
|
if (error) {
|
|
return (
|
|
<IconButton>
|
|
<PlayIcon/>
|
|
</IconButton>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<IconButton onClick={(e) => {
|
|
e.preventDefault()
|
|
e.stopPropagation()
|
|
dispatch(playAlbum(ids[0], data))
|
|
}}>
|
|
<PlayIcon/>
|
|
</IconButton>
|
|
)
|
|
}
|
|
export default GridButton |