From 9552fcd9a9d9b50d20d82bea3bd7f9b9b46b7aca Mon Sep 17 00:00:00 2001 From: Kasper Seweryn Date: Sat, 28 Jan 2023 23:45:15 +0100 Subject: [PATCH] fix: #2053 Part-of: --- front/src/composables/audio/queue.ts | 15 ++++++++++++--- front/src/composables/audio/tracks.ts | 3 +-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/front/src/composables/audio/queue.ts b/front/src/composables/audio/queue.ts index 4caf8d1d8..377628847 100644 --- a/front/src/composables/audio/queue.ts +++ b/front/src/composables/audio/queue.ts @@ -174,7 +174,12 @@ export const useQueue = createGlobalState(() => { await playNext(true) } - tracks.value.splice(index, 1) + if (isShuffled.value) { + tracks.value.splice(tracks.value.indexOf(shuffledIds.value[index]), 1) + shuffledIds.value.splice(index, 1) + } else { + tracks.value.splice(index, 1) + } if (index <= currentIndex.value) { currentIndex.value -= 1 @@ -239,8 +244,12 @@ export const useQueue = createGlobalState(() => { // Reorder const reorder = (from: number, to: number) => { - const [id] = tracks.value.splice(from, 1) - tracks.value.splice(to, 0, id) + const list = isShuffled.value + ? shuffledIds + : tracks + + const [id] = list.value.splice(from, 1) + list.value.splice(to, 0, id) const current = currentIndex.value if (current === from) { diff --git a/front/src/composables/audio/tracks.ts b/front/src/composables/audio/tracks.ts index 195df4ae9..1e35b627e 100644 --- a/front/src/composables/audio/tracks.ts +++ b/front/src/composables/audio/tracks.ts @@ -111,7 +111,6 @@ export const useTracks = createGlobalState(() => { // Preload next track const { start: startPreloadTimeout } = useTimeoutFn(async (index) => { - console.log('@@@@', index) const { queue } = useQueue() const sound = await createSound(queue.value[index as number]) await sound.preload() @@ -170,7 +169,7 @@ export const useTracks = createGlobalState(() => { // NOTE: Preload next track // Calling this function clears previous timeout and starts a new one. // Since this watchEffect fires whenever currentIndex / nextTrack changes, it will automatically cleanup previous preload. - // @ts-expect-error vueuse is wrongly typed? + // @ts-expect-error vueuse is wrongly typed: https://github.com/vueuse/vueuse/issues/2691 startPreloadTimeout(currentIndex.value + 1) })