More indexedDB cleanup

environments/review-docs-renov-b1i8ag/deployments/15025
wvffle 2022-10-28 22:15:15 +00:00 zatwierdzone przez Georg Krause
rodzic eba18cede3
commit cb5e6f1848
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 2970D504B2183D22
1 zmienionych plików z 10 dodań i 2 usunięć

Wyświetl plik

@ -53,6 +53,7 @@ watchEffect(async () => {
if (fetchingTracks.value) return
const allTracks = new Set(tracks.value)
const removedIds = new Set<number>()
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<QueueTrack[]>(() => {