(1) Fix missing image on first track

(2) Dial back the updates in useCurrentTrack
This commit is contained in:
Lei Nelissen
2020-08-25 23:34:35 +02:00
parent edce0329cf
commit 6e85013b5a
2 changed files with 16 additions and 4 deletions

View File

@@ -17,12 +17,19 @@ export default function useCurrentTrack(): Track | undefined {
return;
}
// GUARD: Only retrieve new track if it is different from the one we
// have currently in state.
if (currentTrackId === track?.id){
return;
}
// If it is different, retrieve the track and save it
const currentTrack = await TrackPlayer.getTrack(currentTrackId);
setTrack(currentTrack);
};
fetchTrack();
}, [state]);
}, [state, track, setTrack]);
return track;
}