navidrome/ui/src/audioplayer/PlayerToolbar.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
878 B
JavaScript
Raw Normal View History

import React, { useCallback } from 'react'
2020-08-25 01:38:29 +02:00
import { useGetOne } from 'react-admin'
import { GlobalHotKeys } from 'react-hotkeys'
import { LoveButton, useToggleLove } from '../common'
2021-02-04 00:29:33 +01:00
import { keyMap } from '../hotkeys'
2020-08-25 01:38:29 +02:00
const Placeholder = () => <LoveButton disabled={true} resource={'song'} />
2020-08-25 01:38:29 +02:00
const Toolbar = ({ id }) => {
const { data, loading } = useGetOne('song', id)
const [toggleLove, toggling] = useToggleLove('song', data)
2020-08-25 01:38:29 +02:00
const handlers = {
TOGGLE_LOVE: useCallback(() => toggleLove(), [toggleLove]),
}
return (
<>
<GlobalHotKeys keyMap={keyMap} handlers={handlers} allowChanges />
<LoveButton
record={data}
resource={'song'}
disabled={loading || toggling}
/>
</>
)
2020-08-25 01:38:29 +02:00
}
const PlayerToolbar = ({ id, isRadio }) =>
id && !isRadio ? <Toolbar id={id} /> : <Placeholder />
2020-08-25 01:38:29 +02:00
export default PlayerToolbar