mirror of
https://github.com/Jellify-Music/App.git
synced 2026-01-09 04:19:55 -06:00
optimistically set nowplaying
This commit is contained in:
@@ -126,13 +126,21 @@ const PlayerContextInitializer = () => {
|
||||
const usePlayNewQueue = useMutation({
|
||||
mutationFn: async (mutation: QueueMutation) => {
|
||||
trigger("impactLight");
|
||||
// Optimistically set now playing
|
||||
setNowPlaying(mapDtoToTrack(apiClient!, sessionId, mutation.tracklist[mutation.index ?? 0], QueuingType.FromSelection));
|
||||
|
||||
await resetQueue(false);
|
||||
await addToQueue(mutation.tracklist.map((track) => {
|
||||
return mapDtoToTrack(apiClient!, sessionId, track, QueuingType.FromSelection)
|
||||
}));
|
||||
|
||||
setQueueName(mutation.queueName);
|
||||
await play(mutation.index);
|
||||
},
|
||||
onSuccess: async (data, mutation: QueueMutation) => {
|
||||
await play(mutation.index)
|
||||
},
|
||||
onError: async () => {
|
||||
setNowPlaying(await TrackPlayer.getActiveTrack() as JellifyTrack)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user