Fix Album Grid flickering

This commit is contained in:
Deluan 2021-05-05 15:44:48 -04:00
parent a5fc5f0ff6
commit 9e559311ad
2 changed files with 10 additions and 6 deletions

View File

@ -9,7 +9,7 @@ import {
import { makeStyles } from '@material-ui/core/styles'
import withWidth from '@material-ui/core/withWidth'
import { Link } from 'react-router-dom'
import { linkToRecord, Loading, useListContext } from 'react-admin'
import { linkToRecord, useListContext, Loading } from 'react-admin'
import { withContentRect } from 'react-measure'
import subsonic from '../subsonic'
import {
@ -104,7 +104,7 @@ const Cover = withContentRect('bounds')(
<div ref={measureRef}>
<img
src={subsonic.getCoverArtUrl(album, 300)}
alt={album.album}
alt={album.name}
className={classes.cover}
/>
</div>
@ -113,8 +113,10 @@ const Cover = withContentRect('bounds')(
)
const AlbumGridTile = ({ showArtist, record, basePath }) => {
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'))
const classes = useStyles()
const isDesktop = useMediaQuery((theme) => theme.breakpoints.up('md'), {
noSsr: true,
})
return (
<div className={classes.albumContainer}>
@ -183,7 +185,9 @@ const LoadedAlbumGrid = ({ ids, data, basePath, width }) => {
)
}
const AlbumGridView = ({ loading, ...props }) =>
loading ? <Loading /> : <LoadedAlbumGrid {...props} />
const AlbumGridView = ({ albumListType, loading, ...props }) => {
const hide = loading && albumListType === 'random'
return hide ? <Loading /> : <LoadedAlbumGrid {...props} />
}
export default withWidth()(AlbumGridView)

View File

@ -94,7 +94,7 @@ const AlbumList = (props) => {
title={<AlbumListTitle albumListType={albumListType} />}
>
{albumView.grid ? (
<AlbumGridView {...props} />
<AlbumGridView albumListType={albumListType} {...props} />
) : (
<AlbumListView {...props} />
)}