From 00f442b77ee6b04a486f842bdad83487efb349d5 Mon Sep 17 00:00:00 2001 From: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Date: Sat, 1 Oct 2022 20:58:13 +0600 Subject: [PATCH] Don't download completely read chapter if it was in queue (#8113) --- .../kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index aa7149516..121504521 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -132,7 +132,7 @@ class ReaderPresenter( private val imageSaver: ImageSaver by injectLazy() - private var chapterDownload: Download? = null + private var chapterToDownload: Download? = null /** * Chapter list for the active manga. It's retrieved lazily and should be accessed for the first @@ -206,7 +206,7 @@ class ReaderPresenter( if (currentChapters != null) { currentChapters.unref() saveReadingProgress(currentChapters.currChapter) - chapterDownload?.let { + chapterToDownload?.let { downloadManager.addDownloadsToStartOfQueue(listOf(it)) } } @@ -336,7 +336,7 @@ class ReaderPresenter( newChapters.ref() oldChapters?.unref() - chapterDownload = deleteChapterFromDownloadQueue(newChapters.currChapter) + chapterToDownload = deleteChapterFromDownloadQueue(newChapters.currChapter) viewerChaptersRelay.call(newChapters) } } @@ -511,11 +511,9 @@ class ReaderPresenter( val removeAfterReadSlots = downloadPreferences.removeAfterReadSlots().get() val chapterToDelete = chapterList.getOrNull(currentChapterPosition - removeAfterReadSlots) - if (removeAfterReadSlots != 0 && chapterDownload != null) { - downloadManager.addDownloadsToStartOfQueue(listOf(chapterDownload!!)) - } else { - chapterDownload = null - } + // If chapter is completely read no need to download it + chapterToDownload = null + // Check if deleting option is enabled and chapter exists if (removeAfterReadSlots != -1 && chapterToDelete != null) { enqueueDeleteReadChapters(chapterToDelete)