diff --git a/android/app/src/main/java/com/audiobookshelf/app/plugins/AbsDownloader.kt b/android/app/src/main/java/com/audiobookshelf/app/plugins/AbsDownloader.kt index 57b9aa51..d9dde269 100644 --- a/android/app/src/main/java/com/audiobookshelf/app/plugins/AbsDownloader.kt +++ b/android/app/src/main/java/com/audiobookshelf/app/plugins/AbsDownloader.kt @@ -38,7 +38,9 @@ class AbsDownloader : Plugin() { override fun onDownloadItemComplete(jsobj:JSObject) { notifyListeners("onItemDownloadComplete", jsobj) } - override fun onQueueChanged(hasWork: Boolean) = Unit + override fun onQueueChanged(hasWork: Boolean) { + notifyListeners("onQueueChanged", JSObject().put("hasWork", hasWork)) + } }) override fun load() { diff --git a/components/widgets/DownloadProgressIndicator.vue b/components/widgets/DownloadProgressIndicator.vue index 8e389c7d..be1d502c 100644 --- a/components/widgets/DownloadProgressIndicator.vue +++ b/components/widgets/DownloadProgressIndicator.vue @@ -12,7 +12,8 @@ export default { return { downloadItemListener: null, completeListener: null, - itemPartUpdateListener: null + itemPartUpdateListener: null, + queueChangedListener: null } }, computed: { @@ -76,17 +77,22 @@ export default { }, onDownloadItemPartUpdate(itemPart) { this.$store.commit('globals/updateDownloadItemPart', itemPart) + }, + onQueueChanged(data) { + if (!data.hasWork) this.$store.commit('globals/clearItemDownloads') } }, async mounted() { this.downloadItemListener = await AbsDownloader.addListener('onDownloadItem', (data) => this.onDownloadItem(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)) }, beforeDestroy() { this.downloadItemListener?.remove() this.completeListener?.remove() this.itemPartUpdateListener?.remove() + this.queueChangedListener?.remove() } } \ No newline at end of file diff --git a/store/globals.js b/store/globals.js index 7e80824b..6edad56e 100644 --- a/store/globals.js +++ b/store/globals.js @@ -135,6 +135,9 @@ export const mutations = { removeItemDownload(state, id) { state.itemDownloads = state.itemDownloads.filter((i) => i.id != id) }, + clearItemDownloads(state) { + state.itemDownloads = [] + }, setBookshelfListView(state, val) { state.bookshelfListView = val },