Play track now on click

This commit is contained in:
Jordan Eldredge 2020-04-06 21:30:53 -07:00
parent ed864fab1f
commit 6fc70315e6
3 changed files with 7 additions and 2 deletions

View file

@ -58,6 +58,7 @@ export {
seekBackward,
setVolume,
playTrack,
playTrackNow,
adjustVolume,
scrollVolume,
setBalance,

View file

@ -31,6 +31,10 @@ export function playTrack(id: number): Thunk {
};
}
export function playTrackNow(id: number): Action {
return { type: PLAY_TRACK, id };
}
export function play(): Thunk {
return (dispatch: Dispatch, getState: GetState) => {
const state = getState();

View file

@ -28,7 +28,7 @@ function TrackCell({ children, handleMoveClick, index, id }: Props) {
const current = currentTrackId === id;
const dispatch = useTypedDispatch();
const playTrack = useActionCreator(Actions.playTrack);
const playTrackNow = useActionCreator(Actions.playTrackNow);
const onMouseDown = useCallback(
(e: React.MouseEvent<HTMLDivElement>) => {
@ -62,7 +62,7 @@ function TrackCell({ children, handleMoveClick, index, id }: Props) {
onClick={(e) => e.stopPropagation()}
onMouseDown={onMouseDown}
onContextMenu={(e) => e.preventDefault()}
onDoubleClick={() => playTrack(id)}
onDoubleClick={() => playTrackNow(id)}
>
{children}
</div>