Add multidisc labels, even if there are no disc subtitles

This commit is contained in:
Deluan
2020-05-12 13:14:23 -04:00
parent 4355f4fe2d
commit a88270a22b
+29 -16
View File
@@ -68,17 +68,43 @@ const trackName = (r) => {
return name return name
} }
const AlbumSongs = (props) => {
const classes = useStyles(props)
const classesToolbar = useStylesListToolbar(props)
const dispatch = useDispatch()
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
const controllerProps = useListController(props)
const { bulkActionButtons, albumId, expand, className } = props
const { data, ids, version, loaded } = controllerProps
let multiDisc = false
if (loaded) {
const discSet = new Set()
ids.forEach((id) => discSet.add(data[id].discNumber))
multiDisc = discSet.size > 1
console.log(multiDisc, discSet.size)
}
const anySong = data[ids[0]]
const showPlaceholder = !anySong || anySong.albumId !== albumId
const hasBulkActions = props.bulkActionButtons !== false
const SongDatagridRow = (props) => { const SongDatagridRow = (props) => {
const { record, children } = props const { record, children } = props
return ( return (
<> <>
{record.discSubtitle && record.trackNumber === 1 && ( {multiDisc && (
<TableRow> <TableRow>
{record.trackNumber === 1 && (
<TableCell colSpan={children.length + 1}> <TableCell colSpan={children.length + 1}>
<Typography variant="h6"> <Typography variant="h6">
{record.discSubtitle} (disc {record.discNumber}) {record.discSubtitle
? `${record.discSubtitle} (disc ${record.discNumber})`
: `Disc ${record.discNumber}`}
</Typography> </Typography>
</TableCell> </TableCell>
)}
</TableRow> </TableRow>
)} )}
<DatagridRow {...props} /> <DatagridRow {...props} />
@@ -93,20 +119,6 @@ const SongsDatagrid = (props) => (
<Datagrid {...props} body={<SongsDatagridBody />} /> <Datagrid {...props} body={<SongsDatagridBody />} />
) )
const AlbumSongs = (props) => {
const classes = useStyles(props)
const classesToolbar = useStylesListToolbar(props)
const dispatch = useDispatch()
const isXsmall = useMediaQuery((theme) => theme.breakpoints.down('xs'))
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
const controllerProps = useListController(props)
const { bulkActionButtons, albumId, expand, className } = props
const { data, ids, version } = controllerProps
const anySong = data[ids[0]]
const showPlaceholder = !anySong || anySong.albumId !== albumId
const hasBulkActions = props.bulkActionButtons !== false
return ( return (
<> <>
<ListToolbar <ListToolbar
@@ -144,6 +156,7 @@ const AlbumSongs = (props) => {
rowClick={(id) => dispatch(playAlbum(data, ids, id))} rowClick={(id) => dispatch(playAlbum(data, ids, id))}
{...controllerProps} {...controllerProps}
hasBulkActions={hasBulkActions} hasBulkActions={hasBulkActions}
multiDisc={multiDisc}
> >
{isDesktop && ( {isDesktop && (
<TextField <TextField