Don't download completely read chapter if it was in queue (#8113)

(cherry picked from commit 00f442b77ee6b04a486f842bdad83487efb349d5)
This commit is contained in:
AntsyLich 2022-10-01 20:58:13 +06:00 committed by Jobobby04
parent 1eb1763342
commit c1df5adf2c

View File

@ -167,7 +167,7 @@ class ReaderPresenter(
private val imageSaver: ImageSaver by injectLazy() 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 * Chapter list for the active manga. It's retrieved lazily and should be accessed for the first
@ -254,7 +254,7 @@ class ReaderPresenter(
if (currentChapters != null) { if (currentChapters != null) {
currentChapters.unref() currentChapters.unref()
saveReadingProgress(currentChapters.currChapter) saveReadingProgress(currentChapters.currChapter)
chapterDownload?.let { chapterToDownload?.let {
downloadManager.addDownloadsToStartOfQueue(listOf(it)) downloadManager.addDownloadsToStartOfQueue(listOf(it))
} }
} }
@ -419,7 +419,7 @@ class ReaderPresenter(
newChapters.ref() newChapters.ref()
oldChapters?.unref() oldChapters?.unref()
chapterDownload = deleteChapterFromDownloadQueue(newChapters.currChapter) chapterToDownload = deleteChapterFromDownloadQueue(newChapters.currChapter)
viewerChaptersRelay.call(newChapters) viewerChaptersRelay.call(newChapters)
} }
} }
@ -614,11 +614,9 @@ class ReaderPresenter(
val removeAfterReadSlots = downloadPreferences.removeAfterReadSlots().get() val removeAfterReadSlots = downloadPreferences.removeAfterReadSlots().get()
val chapterToDelete = chapterList.getOrNull(currentChapterPosition - removeAfterReadSlots) val chapterToDelete = chapterList.getOrNull(currentChapterPosition - removeAfterReadSlots)
if (removeAfterReadSlots != 0 && chapterDownload != null) { // If chapter is completely read no need to download it
downloadManager.addDownloadsToStartOfQueue(listOf(chapterDownload!!)) chapterToDownload = null
} else {
chapterDownload = null
}
// Check if deleting option is enabled and chapter exists // Check if deleting option is enabled and chapter exists
if (removeAfterReadSlots != -1 && chapterToDelete != null) { if (removeAfterReadSlots != -1 && chapterToDelete != null) {
enqueueDeleteReadChapters(chapterToDelete) enqueueDeleteReadChapters(chapterToDelete)