Fix download queue not being removed after all items downloaded

This commit is contained in:
Jays2Kings 2021-04-19 03:22:34 -04:00
parent ff5e507255
commit a65ac5cab5
2 changed files with 6 additions and 6 deletions

View File

@ -512,7 +512,7 @@ class Downloader(
// Delete successful downloads from queue
if (download.status == Download.DOWNLOADED) {
// remove downloaded chapter from queue
queue.remove(download, false)
queue.remove(download)
}
if (areAllDownloadsFinished()) {
DownloadService.stop(context)

View File

@ -31,7 +31,7 @@ class DownloadQueue(
updatedRelay.call(Unit)
}
fun remove(download: Download, callListeners: Boolean = true) {
fun remove(download: Download) {
val removed = queue.remove(download)
store.remove(download)
download.setStatusSubject(null)
@ -39,9 +39,7 @@ class DownloadQueue(
if (download.status == Download.DOWNLOADING || download.status == Download.QUEUE) {
download.status = Download.NOT_DOWNLOADED
}
if (callListeners) {
downloadListeners.forEach { it.updateDownload(download) }
}
if (removed) {
updatedRelay.call(Unit)
}
@ -88,7 +86,9 @@ class DownloadQueue(
callListeners(download)
} else if (download.status == Download.DOWNLOADED || download.status == Download.ERROR) {
setPagesSubject(download.pages, null)
if (download.status == Download.ERROR) {
callListeners(download)
}
} else {
callListeners(download)
}