From 41a747c7e799a6cab936e9f4a14979ca7587ef39 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 21 Apr 2021 17:41:43 -0400 Subject: [PATCH] Consider sort direction when downloading next n chapters (fixes #4916) --- .../kanade/tachiyomi/ui/manga/MangaController.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 88c07cc80e..c4025a6a0d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -1004,11 +1004,17 @@ class MangaController : // OVERFLOW MENU DIALOGS - private fun getUnreadChaptersSorted() = presenter.chapters - .sortedWith(presenter.getChapterSort()) - .filter { !it.read && it.status == Download.State.NOT_DOWNLOADED } - .distinctBy { it.name } - .reversed() + private fun getUnreadChaptersSorted(): List { + val chapters = presenter.chapters + .sortedWith(presenter.getChapterSort()) + .filter { !it.read && it.status == Download.State.NOT_DOWNLOADED } + .distinctBy { it.name } + return if (presenter.sortDescending()) { + chapters.reversed() + } else { + chapters + } + } private fun downloadChapters(choice: Int) { val chaptersToDownload = when (choice) {