Skip to content

🎧 Your Personal Streaming Service

added grid play button

Srihari Chandana00666da9c1ee
diff --git a/ui/src/album/AlbumGridView.js b/ui/src/album/AlbumGridView.js
index 02aff060c..1f6610295 100644
--- a/ui/src/album/AlbumGridView.js
+++ b/ui/src/album/AlbumGridView.js
@@ -6,6 +6,7 @@ import { Link } from 'react-router-dom'
import { linkToRecord, Loading } from 'react-admin'
import subsonic from '../subsonic'
import { ArtistLinkField } from './ArtistLinkField'
+import GridButton from './GridButton.js'
const useStyles = makeStyles((theme) => ({
root: {
@@ -80,6 +81,9 @@ const LoadedAlbumGrid = ({ ids, data, basePath, width }) => {
</ArtistLinkField>
</div>
}
+ actionIcon={
+ <GridButton id={id}/>
+ }
/>
</GridListTile>
))}
diff --git a/ui/src/album/GridButton.js b/ui/src/album/GridButton.js
new file mode 100644
index 000000000..84a506510
--- /dev/null
+++ b/ui/src/album/GridButton.js
@@ -0,0 +1,43 @@
+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
\ No newline at end of file