Update download notification cancel to clear download queue in UI

This commit is contained in:
advplyr
2026-07-30 17:31:23 -05:00
parent b084e54dcc
commit e5ef38295d
3 changed files with 13 additions and 2 deletions
@@ -38,7 +38,9 @@ class AbsDownloader : Plugin() {
override fun onDownloadItemComplete(jsobj:JSObject) { override fun onDownloadItemComplete(jsobj:JSObject) {
notifyListeners("onItemDownloadComplete", jsobj) notifyListeners("onItemDownloadComplete", jsobj)
} }
override fun onQueueChanged(hasWork: Boolean) = Unit override fun onQueueChanged(hasWork: Boolean) {
notifyListeners("onQueueChanged", JSObject().put("hasWork", hasWork))
}
}) })
override fun load() { override fun load() {
@@ -12,7 +12,8 @@ export default {
return { return {
downloadItemListener: null, downloadItemListener: null,
completeListener: null, completeListener: null,
itemPartUpdateListener: null itemPartUpdateListener: null,
queueChangedListener: null
} }
}, },
computed: { computed: {
@@ -76,17 +77,22 @@ export default {
}, },
onDownloadItemPartUpdate(itemPart) { onDownloadItemPartUpdate(itemPart) {
this.$store.commit('globals/updateDownloadItemPart', itemPart) this.$store.commit('globals/updateDownloadItemPart', itemPart)
},
onQueueChanged(data) {
if (!data.hasWork) this.$store.commit('globals/clearItemDownloads')
} }
}, },
async mounted() { async mounted() {
this.downloadItemListener = await AbsDownloader.addListener('onDownloadItem', (data) => this.onDownloadItem(data)) this.downloadItemListener = await AbsDownloader.addListener('onDownloadItem', (data) => this.onDownloadItem(data))
this.itemPartUpdateListener = await AbsDownloader.addListener('onDownloadItemPartUpdate', (data) => this.onDownloadItemPartUpdate(data)) this.itemPartUpdateListener = await AbsDownloader.addListener('onDownloadItemPartUpdate', (data) => this.onDownloadItemPartUpdate(data))
this.queueChangedListener = await AbsDownloader.addListener('onQueueChanged', (data) => this.onQueueChanged(data))
this.completeListener = await AbsDownloader.addListener('onItemDownloadComplete', (data) => this.onItemDownloadComplete(data)) this.completeListener = await AbsDownloader.addListener('onItemDownloadComplete', (data) => this.onItemDownloadComplete(data))
}, },
beforeDestroy() { beforeDestroy() {
this.downloadItemListener?.remove() this.downloadItemListener?.remove()
this.completeListener?.remove() this.completeListener?.remove()
this.itemPartUpdateListener?.remove() this.itemPartUpdateListener?.remove()
this.queueChangedListener?.remove()
} }
} }
</script> </script>
+3
View File
@@ -135,6 +135,9 @@ export const mutations = {
removeItemDownload(state, id) { removeItemDownload(state, id) {
state.itemDownloads = state.itemDownloads.filter((i) => i.id != id) state.itemDownloads = state.itemDownloads.filter((i) => i.id != id)
}, },
clearItemDownloads(state) {
state.itemDownloads = []
},
setBookshelfListView(state, val) { setBookshelfListView(state, val) {
state.bookshelfListView = val state.bookshelfListView = val
}, },