Cleanup indexedDB when queue clears and when instance changes

This commit is contained in:
wvffle 2022-10-28 22:09:51 +00:00 committed by Georg Krause
commit eba18cede3
No known key found for this signature in database
GPG key ID: 2970D504B2183D22
2 changed files with 9 additions and 1 deletions

View file

@ -3,7 +3,7 @@ import type { Track, Upload } from '~/types'
import { createGlobalState, useNow, useStorage, useTimeAgo, whenever } from '@vueuse/core'
import { shuffle as shuffleArray, sum } from 'lodash-es'
import { computed, ref, shallowReactive, watchEffect } from 'vue'
import { getMany, setMany } from 'idb-keyval'
import { delMany, getMany, setMany } from 'idb-keyval'
import { useClamp } from '@vueuse/math'
import { looping, LoopingMode, isPlaying } from '~/composables/audio/player'
@ -277,8 +277,12 @@ export const useQueue = createGlobalState(() => {
currentSound.value?.pause()
currentSound.value?.seekTo(0)
currentSound.value?.dispose()
clearRadio.value = true
const lastTracks = [...tracks.value]
tracks.value.length = 0
await delMany(lastTracks)
}
// Radio queue populating