Fix theme not being applied to PlayerToolbar

This commit is contained in:
Deluan 2021-03-27 14:24:59 -04:00
parent ac37bf3631
commit b42532dd7c

View File

@ -4,11 +4,15 @@ import { useGetOne } from 'react-admin'
import { GlobalHotKeys } from 'react-hotkeys' import { GlobalHotKeys } from 'react-hotkeys'
import { LoveButton, useToggleLove } from '../common' import { LoveButton, useToggleLove } from '../common'
import { keyMap } from '../hotkeys' import { keyMap } from '../hotkeys'
import { ThemeProvider } from '@material-ui/styles'
import { createMuiTheme } from '@material-ui/core/styles'
import useCurrentTheme from '../themes/useCurrentTheme'
const Placeholder = () => <LoveButton disabled={true} resource={'song'} /> const Placeholder = () => <LoveButton disabled={true} resource={'song'} />
const Toolbar = ({ id }) => { const Toolbar = ({ id }) => {
const location = useLocation() const location = useLocation()
const theme = useCurrentTheme()
const resource = location.pathname.startsWith('/song') ? 'song' : 'albumSong' const resource = location.pathname.startsWith('/song') ? 'song' : 'albumSong'
const { data, loading } = useGetOne(resource, id) const { data, loading } = useGetOne(resource, id)
const [toggleLove, toggling] = useToggleLove(resource, data) const [toggleLove, toggling] = useToggleLove(resource, data)
@ -18,14 +22,14 @@ const Toolbar = ({ id }) => {
} }
return ( return (
<> <ThemeProvider theme={createMuiTheme(theme)}>
<GlobalHotKeys keyMap={keyMap} handlers={handlers} allowChanges /> <GlobalHotKeys keyMap={keyMap} handlers={handlers} allowChanges />
<LoveButton <LoveButton
record={data} record={data}
resource={resource} resource={resource}
disabled={loading || toggling} disabled={loading || toggling}
/> />
</> </ThemeProvider>
) )
} }