Revert "Show indicator on current playing song. Fixes #128"

This implementation causes performance issues
This commit is contained in:
Deluan
2020-06-13 16:39:57 -04:00
parent 86bc8d97a0
commit 72b2e756f7
9 changed files with 31 additions and 109 deletions
-65
View File
@@ -1,65 +0,0 @@
import { makeStyles } from '@material-ui/core/styles'
import React from 'react'
import PropTypes from 'prop-types'
import { useSelector } from 'react-redux'
import { FunctionField } from 'react-admin'
import get from 'lodash.get'
import { useTheme } from '@material-ui/core/styles'
import PlayingLight from '../icons/playing-light.gif'
import PlayingDark from '../icons/playing-dark.gif'
const useStyles = makeStyles({
playingIcon: {
width: '20px',
height: '20px',
verticalAlign: 'text-top',
marginTop: '-2px',
paddingRight: '3px',
},
})
const SongTitleField = ({ showTrackNumbers, ...props }) => {
const theme = useTheme()
const classes = useStyles()
const { record } = props
const currentTrack = useSelector((state) => get(state, 'queue.current', {}))
const currentId = currentTrack.trackId
const paused = currentTrack.paused
const isCurrent =
currentId &&
!paused &&
(currentId === record.id || currentId === record.mediaFileId)
const trackName = (r) => {
const name = r.title
if (r.trackNumber && showTrackNumbers) {
return r.trackNumber.toString().padStart(2, '0') + ' ' + name
}
return name
}
return (
<>
{isCurrent && (
<img
src={theme.palette.type === 'light' ? PlayingLight : PlayingDark}
className={classes.playingIcon}
alt="playing"
/>
)}
<FunctionField
{...props}
source="title"
render={trackName}
sortable={false}
/>
</>
)
}
SongTitleField.propTypes = {
record: PropTypes.object,
showTrackNumbers: PropTypes.bool,
}
export default SongTitleField
-2
View File
@@ -12,7 +12,6 @@ import DocLink from './DocLink'
import List from './List'
import { SongDatagrid, SongDatagridRow } from './SongDatagrid'
import SongContextMenu from './SongContextMenu'
import SongTitleField from './SongTitleField'
import QuickFilter from './QuickFilter'
import useAlbumsPerPage from './useAlbumsPerPage'
@@ -29,7 +28,6 @@ export {
SongDetails,
SongDatagrid,
SongDatagridRow,
SongTitleField,
DocLink,
formatRange,
ArtistLinkField,