More indexedDB cleanup
This commit is contained in:
parent
eba18cede3
commit
cb5e6f1848
|
@ -53,6 +53,7 @@ watchEffect(async () => {
|
||||||
if (fetchingTracks.value) return
|
if (fetchingTracks.value) return
|
||||||
|
|
||||||
const allTracks = new Set(tracks.value)
|
const allTracks = new Set(tracks.value)
|
||||||
|
const removedIds = new Set<number>()
|
||||||
const addedIds = new Set(allTracks)
|
const addedIds = new Set(allTracks)
|
||||||
|
|
||||||
for (const id of tracksById.keys()) {
|
for (const id of tracksById.keys()) {
|
||||||
|
@ -60,8 +61,8 @@ watchEffect(async () => {
|
||||||
// Track in queue, so remove it from the new ids set
|
// Track in queue, so remove it from the new ids set
|
||||||
addedIds.delete(id)
|
addedIds.delete(id)
|
||||||
} else {
|
} else {
|
||||||
// Track removed from queue, so remove it from the object
|
// Track removed from queue, so remove it from the object and db later
|
||||||
tracksById.delete(id)
|
removedIds.add(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +79,13 @@ watchEffect(async () => {
|
||||||
fetchingTracks.value = false
|
fetchingTracks.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (removedIds.size > 0) {
|
||||||
|
await delMany([...removedIds])
|
||||||
|
for (const id of removedIds) {
|
||||||
|
tracksById.delete(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const queue = computed<QueueTrack[]>(() => {
|
const queue = computed<QueueTrack[]>(() => {
|
||||||
|
|
Loading…
Reference in New Issue