From 3cf390778fa2ab326c0f85a93f3068c6439d80c4 Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Mon, 6 Jan 2025 12:06:14 -0800 Subject: [PATCH 1/2] fix: lint --- src/components/player/controls/usePlayerControls.ts | 1 + src/components/playlist/usePlaylistRN.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/components/player/controls/usePlayerControls.ts b/src/components/player/controls/usePlayerControls.ts index 265c1009..ce2bf2d6 100644 --- a/src/components/player/controls/usePlayerControls.ts +++ b/src/components/player/controls/usePlayerControls.ts @@ -189,6 +189,7 @@ export default () => { ); TrackPlayer.seekTo(trackDuration * newABRepeat[0]); }, + funcName: 'ABRepeat A seek', }); }); diff --git a/src/components/playlist/usePlaylistRN.ts b/src/components/playlist/usePlaylistRN.ts index 043c82dd..4bf29572 100644 --- a/src/components/playlist/usePlaylistRN.ts +++ b/src/components/playlist/usePlaylistRN.ts @@ -137,6 +137,7 @@ export default (playlist: NoxMedia.Playlist) => { let layoutHeightCheck = 0; if (currentIndex > -1) { execWhenTrue({ + funcName: 'playlist index priming', executeFn: () => playlistRef.current?.scrollToIndex({ index: currentIndex, From e972f5ec13cd843722f6dc3bcea9c5749aa89484 Mon Sep 17 00:00:00 2001 From: lovegaoshi <106490582+lovegaoshi@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:38:38 -0800 Subject: [PATCH 2/2] fix: playSong repriming currentPlayingList --- src/components/playlist/usePlaylistRN.ts | 6 ++++-- src/hooks/usePlaylist.ts | 14 +++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/components/playlist/usePlaylistRN.ts b/src/components/playlist/usePlaylistRN.ts index 4bf29572..e03a1acb 100644 --- a/src/components/playlist/usePlaylistRN.ts +++ b/src/components/playlist/usePlaylistRN.ts @@ -14,7 +14,6 @@ import { syncFavlist } from '@utils/Bilibili/bilifavOperate'; import usePlayback from '@hooks/usePlayback'; import useTPControls from '@hooks/useTPControls'; import useSnack from '@stores/useSnack'; -import { setPlayingList } from '@stores/playingList'; import { clearPlaylistUninterrupted } from '@utils/RNTPUtils'; import { execWhenTrue } from '@utils/Utils'; @@ -52,6 +51,9 @@ export default (playlist: NoxMedia.Playlist) => { const playlistShouldReRender = useNoxSetting( state => state.playlistShouldReRender, ); + const setCurrentPlayingList = useNoxSetting( + state => state.setCurrentPlayingList, + ); const progressEmitter = useNoxSetting( state => state.searchBarProgressEmitter, ); @@ -120,7 +122,7 @@ export default (playlist: NoxMedia.Playlist) => { performFade(callback); }; usedPlaylist.playSong(song, playSongCallback, p => - clearPlaylistUninterrupted().then(() => setPlayingList(p.songList)), + clearPlaylistUninterrupted().then(() => setCurrentPlayingList(p)), ); }; diff --git a/src/hooks/usePlaylist.ts b/src/hooks/usePlaylist.ts index 823ff082..9904559d 100644 --- a/src/hooks/usePlaylist.ts +++ b/src/hooks/usePlaylist.ts @@ -119,15 +119,19 @@ const usePlaylist = (playlist: NoxMedia.Playlist): UsePlaylist => { callback: (p: NoxMedia.Playlist, s: NoxMedia.Song) => void, isPlayingCallback: (p: NoxMedia.Playlist) => void = () => undefined, ) => { - if (song.id === currentPlayingId && playlist.id === currentPlayingList.id) - return isPlayingCallback(currentPlayingList); + const queuedSongList = playerSetting.keepSearchedSongListWhenPlaying + ? rows + : playlist.songList; + if (song.id === currentPlayingId && playlist.id === currentPlayingList.id) { + return isPlayingCallback({ + ...currentPlayingList, + songList: queuedSongList, + }); + } // HACK: more responsive, so the current song banner will show // immediately instead of watiting for fade to complete // REVIEW: playfromplaylist also checks currentPlayingId. how is that possible? setCurrentPlayingId(song.id); - const queuedSongList = playerSetting.keepSearchedSongListWhenPlaying - ? rows - : playlist.songList; return callback({ ...playlist, songList: queuedSongList }, song); };