mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-17 22:47:29 +01:00
Fix related to cancelling queued chapters (#8528)
Tachi removes the downloaded chapter (if it exists) when you just cancelled a download from queue. PR fixes that Also removes redundant return
This commit is contained in:
@@ -479,7 +479,7 @@ class DownloadController :
|
||||
presenter.reorder(selectedSeries + otherSeries)
|
||||
}
|
||||
R.id.cancel_download -> {
|
||||
presenter.cancelDownload(item.download)
|
||||
presenter.cancelDownloads(listOf(item.download))
|
||||
}
|
||||
R.id.cancel_series -> {
|
||||
val allDownloadsForSeries = adapter?.currentItems
|
||||
|
||||
@@ -72,11 +72,7 @@ class DownloadPresenter : BasePresenter<DownloadController>() {
|
||||
downloadManager.reorderQueue(downloads)
|
||||
}
|
||||
|
||||
fun cancelDownload(download: Download) {
|
||||
downloadManager.deletePendingDownload(download)
|
||||
}
|
||||
|
||||
fun cancelDownloads(downloads: List<Download>) {
|
||||
downloadManager.deletePendingDownloads(*downloads.toTypedArray())
|
||||
downloadManager.deletePendingDownloads(downloads)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -658,7 +658,7 @@ class MangaInfoScreenModel(
|
||||
|
||||
fun cancelDownload(chapterId: Long) {
|
||||
val activeDownload = downloadManager.queue.find { chapterId == it.chapter.id } ?: return
|
||||
downloadManager.deletePendingDownload(activeDownload)
|
||||
downloadManager.deletePendingDownloads(listOf(activeDownload))
|
||||
updateDownloadState(activeDownload.apply { status = Download.State.NOT_DOWNLOADED })
|
||||
}
|
||||
|
||||
|
||||
@@ -490,8 +490,8 @@ class ReaderPresenter(
|
||||
* if setting is enabled and [currentChapter] is queued for download
|
||||
*/
|
||||
private fun deleteChapterFromDownloadQueue(currentChapter: ReaderChapter): Download? {
|
||||
return downloadManager.getChapterDownloadOrNull(currentChapter.chapter.toDomainChapter()!!)?.apply {
|
||||
downloadManager.deletePendingDownload(this)
|
||||
return downloadManager.getChapterDownloadOrNull(currentChapter.chapter.toDomainChapter()!!)?.also {
|
||||
downloadManager.deletePendingDownloads(listOf(it))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ class UpdatesPresenter(
|
||||
|
||||
private fun cancelDownload(chapterId: Long) {
|
||||
val activeDownload = downloadManager.queue.find { chapterId == it.chapter.id } ?: return
|
||||
downloadManager.deletePendingDownload(activeDownload)
|
||||
downloadManager.deletePendingDownloads(listOf(activeDownload))
|
||||
updateDownloadState(activeDownload.apply { status = Download.State.NOT_DOWNLOADED })
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user