Skip to content

Commit

Permalink
Merge pull request #712 from lovegaoshi/dev
Browse files Browse the repository at this point in the history
fix: playSong's currentPlayingList
  • Loading branch information
lovegaoshi authored Jan 6, 2025
2 parents 9d96e83 + e972f5e commit 0600907
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/components/player/controls/usePlayerControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ export default () => {
);
TrackPlayer.seekTo(trackDuration * newABRepeat[0]);
},
funcName: 'ABRepeat A seek',
});
});

Expand Down
7 changes: 5 additions & 2 deletions src/components/playlist/usePlaylistRN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -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)),
);
};

Expand All @@ -137,6 +139,7 @@ export default (playlist: NoxMedia.Playlist) => {
let layoutHeightCheck = 0;
if (currentIndex > -1) {
execWhenTrue({
funcName: 'playlist index priming',
executeFn: () =>
playlistRef.current?.scrollToIndex({
index: currentIndex,
Expand Down
14 changes: 9 additions & 5 deletions src/hooks/usePlaylist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit 0600907

Please sign in to comment.