mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
[bugfix]: set index to current track when unshuffling
This commit is contained in:
@@ -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 = [];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user