From bb817d8af055015ce88d4af64b26627ba3fe1b69 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Mon, 16 Nov 2026 20:19:00 -0500 Subject: [PATCH] fix(mobile): show restored position before playback resumes A paused player sends no status updates after it loads, so a restored position waited until Play to apply and the slider showed 0:00. Seek right away when the song is already loaded, and show the position. Co-Authored-By: Claude Opus 5.5 --- apps/mobile/hooks/use-native-playlist-sync.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) 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 }, [])