From 6cfa8f7624ac4ace93e8d4087def751a23279077 Mon Sep 17 00:00:00 2001 From: Lei Nelissen Date: Thu, 11 Feb 2021 23:55:49 +0100 Subject: [PATCH] Attempt fix for JELLYFIN-AUDIO-PLAYER-M --- src/utility/useCurrentTrack.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utility/useCurrentTrack.ts b/src/utility/useCurrentTrack.ts index 13dcf9b..df412b3 100644 --- a/src/utility/useCurrentTrack.ts +++ b/src/utility/useCurrentTrack.ts @@ -24,8 +24,15 @@ export default function useCurrentTrack(): Track | undefined { } // If it is different, retrieve the track and save it - const currentTrack = await TrackPlayer.getTrack(currentTrackId); - setTrack(currentTrack); + try { + const currentTrack = await TrackPlayer.getTrack(currentTrackId); + setTrack(currentTrack); + } catch { + // Due to the async nature, a track might be removed at the + // point when we try to retrieve it. If this happens, we'll just + // smother the error and wait for a new track update to + // finish. + } }; fetchTrack();