From 6fc70315e667890cfa8db4ffa6be9a88c54ec209 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Mon, 6 Apr 2020 21:30:53 -0700 Subject: [PATCH] Play track now on click --- js/actionCreators/index.ts | 1 + js/actionCreators/media.ts | 4 ++++ js/components/PlaylistWindow/TrackCell.tsx | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/js/actionCreators/index.ts b/js/actionCreators/index.ts index 6fb2fb02..9a351e27 100644 --- a/js/actionCreators/index.ts +++ b/js/actionCreators/index.ts @@ -58,6 +58,7 @@ export { seekBackward, setVolume, playTrack, + playTrackNow, adjustVolume, scrollVolume, setBalance, diff --git a/js/actionCreators/media.ts b/js/actionCreators/media.ts index 4b44d92a..05e37d5d 100644 --- a/js/actionCreators/media.ts +++ b/js/actionCreators/media.ts @@ -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(); diff --git a/js/components/PlaylistWindow/TrackCell.tsx b/js/components/PlaylistWindow/TrackCell.tsx index 7276ed0e..408a0b07 100644 --- a/js/components/PlaylistWindow/TrackCell.tsx +++ b/js/components/PlaylistWindow/TrackCell.tsx @@ -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) => { @@ -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}