diff --git a/apps/mobile/hooks/use-native-playlist-sync.ts b/apps/mobile/hooks/use-native-playlist-sync.ts index 9b6660e..f2fa1bf 100644 --- a/apps/mobile/hooks/use-native-playlist-sync.ts +++ b/apps/mobile/hooks/use-native-playlist-sync.ts @@ -656,7 +656,28 @@ export function useNativePlaylistSync({ [settleWaiters] ) + /** + * Moves the current song to `seconds` as soon as it is loaded. A paused + * player sends no further status updates once loaded, so seek right away + * when it already is, and show the position either way. + */ const queueSeek = useCallback((seconds: number) => { + currentTimeRef.current = seconds + setCurrentTime(seconds) + const playlist = playlistRef.current + const songId = storeRef.current.getState().queue[0] + if ( + playlist?.isLoaded && + loadedSongIdsRef.current[playlist.currentIndex] === songId + ) { + pendingSeekRef.current = null + // Statuses report the old position until the seek lands. + seekInFlightRef.current = true + void playlist.seekTo(seconds).finally(() => { + seekInFlightRef.current = false + }) + return + } pendingSeekRef.current = seconds }, [])