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 // Delete successful downloads from queue
if (download.status == Download.DOWNLOADED) { if (download.status == Download.DOWNLOADED) {
// remove downloaded chapter from queue // remove downloaded chapter from queue
queue.remove(download, false) queue.remove(download)
} }
if (areAllDownloadsFinished()) { if (areAllDownloadsFinished()) {
DownloadService.stop(context) DownloadService.stop(context)

View File

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