Refactor: move multiDisc detection logic to SongDatagrid

This commit is contained in:
Deluan
2020-05-29 12:20:17 -04:00
parent 915b701e44
commit ba8c8725dd
2 changed files with 25 additions and 18 deletions
+2 -11
View File
@@ -78,16 +78,7 @@ const AlbumSongs = (props) => {
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
const controllerProps = useListController(props)
const { bulkActionButtons, albumId, className } = props
const { data, ids, version, loaded } = controllerProps
let multiDisc = false
if (loaded) {
const discNumbers = ids
.map((id) => data[id])
.filter((r) => r)
.map((r) => r.discNumber)
multiDisc = new Set(discNumbers).size > 1
}
const { data, ids, version } = controllerProps
const anySong = data[ids[0]]
const showPlaceholder = !anySong || anySong.albumId !== albumId
@@ -130,7 +121,7 @@ const AlbumSongs = (props) => {
rowClick={(id) => dispatch(playTracks(data, ids, id))}
{...controllerProps}
hasBulkActions={hasBulkActions}
multiDisc={multiDisc}
showDiscSubtitles={true}
contextAlwaysVisible={!isDesktop}
>
{isDesktop && (