Clean up code a bit

This commit is contained in:
Deluan 2020-09-06 11:54:30 -04:00
parent a25044bdf6
commit 34af6fc671
3 changed files with 19 additions and 21 deletions

View File

@ -1,4 +1,5 @@
import React from 'react'
import PropTypes from 'prop-types'
import { useDispatch } from 'react-redux'
import {
Button,
@ -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()
@ -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)}>
@ -71,7 +64,13 @@ const AlbumActions = ({
)
}
AlbumActions.propTypes = {
record: PropTypes.object.isRequired,
selectedIds: PropTypes.arrayOf(PropTypes.number),
}
AlbumActions.defaultProps = {
record: {},
selectedIds: [],
onUnselectItems: () => null,
}

View File

@ -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}

View File

@ -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()
@ -98,7 +91,13 @@ const PlaylistActions = ({
)
}
PlaylistActions.propTypes = {
record: PropTypes.object.isRequired,
selectedIds: PropTypes.arrayOf(PropTypes.number),
}
PlaylistActions.defaultProps = {
record: {},
selectedIds: [],
onUnselectItems: () => null,
}