Skip to content

Commit

Permalink
Clean up code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
deluan committed Sep 6, 2020
1 parent a25044b commit 34af6fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
21 changes: 10 additions & 11 deletions ui/src/album/AlbumActions.js
@@ -1,4 +1,5 @@
import React from 'react'
import PropTypes from 'prop-types'
import { useDispatch } from 'react-redux'
import {
Button,
Expand All @@ -13,15 +14,7 @@ import AddToQueueIcon from '@material-ui/icons/AddToQueue'
import { addTracks, playTracks, shuffleTracks } from '../audioplayer'
import subsonic from '../subsonic'

const AlbumActions = ({
albumId,
className,
ids,
data,
exporter,
permanentFilter,
...rest
}) => {
const AlbumActions = ({ className, ids, data, record, ...rest }) => {
const dispatch = useDispatch()
const translate = useTranslate()

Expand All @@ -38,8 +31,8 @@ const AlbumActions = ({
}, [dispatch, data, ids])

const handleDownload = React.useCallback(() => {
subsonic.download(albumId)
}, [albumId])
subsonic.download(record.id)
}, [record])

return (
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
Expand Down Expand Up @@ -71,7 +64,13 @@ const AlbumActions = ({
)
}

AlbumActions.propTypes = {
record: PropTypes.object.isRequired,
selectedIds: PropTypes.arrayOf(PropTypes.number),
}

AlbumActions.defaultProps = {
record: {},
selectedIds: [],
onUnselectItems: () => null,
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/album/AlbumShow.js
Expand Up @@ -26,7 +26,7 @@ const AlbumShow = (props) => {
{...props}
albumId={props.id}
title={<Title subTitle={record.name} />}
actions={<AlbumActions albumId={props.id} />}
actions={<AlbumActions record={record} />}
filter={{ album_id: props.id }}
resource={'albumSong'}
exporter={false}
Expand Down
17 changes: 8 additions & 9 deletions ui/src/playlist/PlaylistActions.js
Expand Up @@ -15,16 +15,9 @@ import { httpClient } from '../dataProvider'
import { addTracks, playTracks, shuffleTracks } from '../audioplayer'
import { M3U_MIME_TYPE, REST_URL } from '../consts'
import subsonic from '../subsonic'
import PropTypes from 'prop-types'

const PlaylistActions = ({
className,
ids,
data,
exporter,
permanentFilter,
record,
...rest
}) => {
const PlaylistActions = ({ className, ids, data, record, ...rest }) => {
const dispatch = useDispatch()
const translate = useTranslate()

Expand Down Expand Up @@ -98,7 +91,13 @@ const PlaylistActions = ({
)
}

PlaylistActions.propTypes = {
record: PropTypes.object.isRequired,
selectedIds: PropTypes.arrayOf(PropTypes.number),
}

PlaylistActions.defaultProps = {
record: {},
selectedIds: [],
onUnselectItems: () => null,
}
Expand Down

0 comments on commit 34af6fc

Please sign in to comment.