handle default behavior

This commit is contained in:
SrGooglo 2023-07-12 11:11:51 +00:00
parent 969a3e164e
commit 618e3c88e1

View File

@ -22,6 +22,15 @@ export default (props) => {
const isCurrent = currentManifest?._id === props.track._id const isCurrent = currentManifest?._id === props.track._id
const isPlaying = isCurrent && playbackStatus === "playing" const isPlaying = isCurrent && playbackStatus === "playing"
const handleClickPlayBtn = React.useCallback(() => {
if (typeof props.onClickPlayBtn === "function") {
props.onClick(props.track)
} else {
console.warn("Searcher: onClick is not a function, using default action...")
app.cores.player.start(props.track)
}
})
return <div return <div
id={props.track._id} id={props.track._id}
className={classnames( className={classnames(
@ -48,7 +57,7 @@ export default (props) => {
type="primary" type="primary"
shape="circle" shape="circle"
icon={isPlaying ? <Icons.MdPause /> : <Icons.MdPlayArrow />} icon={isPlaying ? <Icons.MdPause /> : <Icons.MdPlayArrow />}
onClick={props.onClick} onClick={handleClickPlayBtn}
/> />
</div> </div>
</div> </div>