From a537642990ccce2dcc7604ad56507ea66425c1bf Mon Sep 17 00:00:00 2001 From: Kendall Garner <17521368+kgarner7@users.noreply.github.com> Date: Tue, 20 Aug 2024 19:10:05 -0700 Subject: [PATCH] [bugfix]: set index to current track when unshuffling --- src/renderer/store/player.store.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/renderer/store/player.store.ts b/src/renderer/store/player.store.ts index 6e2a8286..80c1d240 100644 --- a/src/renderer/store/player.store.ts +++ b/src/renderer/store/player.store.ts @@ -888,8 +888,19 @@ export const usePlayerStore = create()( }, setShuffle: (type: PlayerShuffle) => { 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) => { state.shuffle = type; + state.current.index = currentIndex; state.queue.shuffled = []; });