[bugfix]: set index to current track when unshuffling

This commit is contained in:
Kendall Garner 2024-08-20 19:10:05 -07:00
parent 9c6abcb32c
commit a537642990
No known key found for this signature in database
GPG key ID: 18D2767419676C87

View file

@ -888,8 +888,19 @@ export const usePlayerStore = create<PlayerSlice>()(
}, },
setShuffle: (type: PlayerShuffle) => { setShuffle: (type: PlayerShuffle) => {
if (type === PlayerShuffle.NONE) { if (type === PlayerShuffle.NONE) {
const currentSongId = get().current.song?.uniqueId;
let currentIndex = 0;
if (currentSongId) {
currentIndex = get().queue.default.findIndex(
(song) => song.uniqueId === currentSongId,
);
}
set((state) => { set((state) => {
state.shuffle = type; state.shuffle = type;
state.current.index = currentIndex;
state.queue.shuffled = []; state.queue.shuffled = [];
}); });