Skip to content

Commit

Permalink
fix: show empty queue when resetting state
Browse files Browse the repository at this point in the history
  • Loading branch information
leinelissen committed Apr 27, 2023
1 parent 0bf2775 commit dd220ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utility/useCurrentTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ export default function useCurrentTrack(): CurrentTrackResponse {
if (currentTrackIndex !== null) {
setTrack(queue[currentTrackIndex]);
setIndex(currentTrackIndex);
} else {
setTrack(undefined);
setIndex(undefined);
}
}, [setTrack, setIndex]);

// Then execute the function on component mount and track changes
useEffect(() => { retrieveCurrentTrack(); }, [retrieveCurrentTrack]);
useTrackPlayerEvents([ Event.PlaybackTrackChanged ], retrieveCurrentTrack);
useTrackPlayerEvents([ Event.PlaybackTrackChanged, Event.PlaybackState ], retrieveCurrentTrack);

return { track, index };
}

0 comments on commit dd220ec

Please sign in to comment.