diff --git a/front/src/composables/audio/queue.ts b/front/src/composables/audio/queue.ts index 00471f745..5516473c9 100644 --- a/front/src/composables/audio/queue.ts +++ b/front/src/composables/audio/queue.ts @@ -53,6 +53,7 @@ watchEffect(async () => { if (fetchingTracks.value) return const allTracks = new Set(tracks.value) + const removedIds = new Set() const addedIds = new Set(allTracks) for (const id of tracksById.keys()) { @@ -60,8 +61,8 @@ watchEffect(async () => { // Track in queue, so remove it from the new ids set addedIds.delete(id) } else { - // Track removed from queue, so remove it from the object - tracksById.delete(id) + // Track removed from queue, so remove it from the object and db later + removedIds.add(id) } } @@ -78,6 +79,13 @@ watchEffect(async () => { fetchingTracks.value = false } } + + if (removedIds.size > 0) { + await delMany([...removedIds]) + for (const id of removedIds) { + tracksById.delete(id) + } + } }) const queue = computed(() => {