Clean up code a bit
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
import { useDispatch } from 'react-redux'
|
import { useDispatch } from 'react-redux'
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -13,15 +14,7 @@ import AddToQueueIcon from '@material-ui/icons/AddToQueue'
|
|||||||
import { addTracks, playTracks, shuffleTracks } from '../audioplayer'
|
import { addTracks, playTracks, shuffleTracks } from '../audioplayer'
|
||||||
import subsonic from '../subsonic'
|
import subsonic from '../subsonic'
|
||||||
|
|
||||||
const AlbumActions = ({
|
const AlbumActions = ({ className, ids, data, record, ...rest }) => {
|
||||||
albumId,
|
|
||||||
className,
|
|
||||||
ids,
|
|
||||||
data,
|
|
||||||
exporter,
|
|
||||||
permanentFilter,
|
|
||||||
...rest
|
|
||||||
}) => {
|
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
|
|
||||||
@@ -38,8 +31,8 @@ const AlbumActions = ({
|
|||||||
}, [dispatch, data, ids])
|
}, [dispatch, data, ids])
|
||||||
|
|
||||||
const handleDownload = React.useCallback(() => {
|
const handleDownload = React.useCallback(() => {
|
||||||
subsonic.download(albumId)
|
subsonic.download(record.id)
|
||||||
}, [albumId])
|
}, [record])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
|
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
|
||||||
@@ -71,7 +64,13 @@ const AlbumActions = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AlbumActions.propTypes = {
|
||||||
|
record: PropTypes.object.isRequired,
|
||||||
|
selectedIds: PropTypes.arrayOf(PropTypes.number),
|
||||||
|
}
|
||||||
|
|
||||||
AlbumActions.defaultProps = {
|
AlbumActions.defaultProps = {
|
||||||
|
record: {},
|
||||||
selectedIds: [],
|
selectedIds: [],
|
||||||
onUnselectItems: () => null,
|
onUnselectItems: () => null,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const AlbumShow = (props) => {
|
|||||||
{...props}
|
{...props}
|
||||||
albumId={props.id}
|
albumId={props.id}
|
||||||
title={<Title subTitle={record.name} />}
|
title={<Title subTitle={record.name} />}
|
||||||
actions={<AlbumActions albumId={props.id} />}
|
actions={<AlbumActions record={record} />}
|
||||||
filter={{ album_id: props.id }}
|
filter={{ album_id: props.id }}
|
||||||
resource={'albumSong'}
|
resource={'albumSong'}
|
||||||
exporter={false}
|
exporter={false}
|
||||||
|
|||||||
@@ -15,16 +15,9 @@ import { httpClient } from '../dataProvider'
|
|||||||
import { addTracks, playTracks, shuffleTracks } from '../audioplayer'
|
import { addTracks, playTracks, shuffleTracks } from '../audioplayer'
|
||||||
import { M3U_MIME_TYPE, REST_URL } from '../consts'
|
import { M3U_MIME_TYPE, REST_URL } from '../consts'
|
||||||
import subsonic from '../subsonic'
|
import subsonic from '../subsonic'
|
||||||
|
import PropTypes from 'prop-types'
|
||||||
|
|
||||||
const PlaylistActions = ({
|
const PlaylistActions = ({ className, ids, data, record, ...rest }) => {
|
||||||
className,
|
|
||||||
ids,
|
|
||||||
data,
|
|
||||||
exporter,
|
|
||||||
permanentFilter,
|
|
||||||
record,
|
|
||||||
...rest
|
|
||||||
}) => {
|
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch()
|
||||||
const translate = useTranslate()
|
const translate = useTranslate()
|
||||||
|
|
||||||
@@ -98,7 +91,13 @@ const PlaylistActions = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlaylistActions.propTypes = {
|
||||||
|
record: PropTypes.object.isRequired,
|
||||||
|
selectedIds: PropTypes.arrayOf(PropTypes.number),
|
||||||
|
}
|
||||||
|
|
||||||
PlaylistActions.defaultProps = {
|
PlaylistActions.defaultProps = {
|
||||||
|
record: {},
|
||||||
selectedIds: [],
|
selectedIds: [],
|
||||||
onUnselectItems: () => null,
|
onUnselectItems: () => null,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user