From 498abf3c3d697dcf07995265ff3ccf42ed779069 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Thu, 13 Nov 2025 18:48:11 -0800 Subject: [PATCH] update player shuffleAll to keep current song index in place --- src/renderer/store/player.store.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/renderer/store/player.store.ts b/src/renderer/store/player.store.ts index ebb962c1e..76f5a5b9d 100644 --- a/src/renderer/store/player.store.ts +++ b/src/renderer/store/player.store.ts @@ -1031,7 +1031,25 @@ export const usePlayerStoreBase = create()( shuffleAll: () => { set((state) => { const queue = state.queue.default; - state.queue.default = shuffleInPlace([...queue]); + const currentIndex = state.player.index; + + // If there's a current song playing, keep it in place + if (currentIndex >= 0 && currentIndex < queue.length) { + const currentSong = queue[currentIndex]; + const beforeCurrent = queue.slice(0, currentIndex); + const afterCurrent = queue.slice(currentIndex + 1); + + const shuffledBefore = shuffleInPlace([...beforeCurrent]); + const shuffledAfter = shuffleInPlace([...afterCurrent]); + + state.queue.default = [ + ...shuffledBefore, + currentSong, + ...shuffledAfter, + ]; + } else { + state.queue.default = shuffleInPlace([...queue]); + } }); }, shuffleSelected: (items: QueueSong[]) => {