From 8882cd4787040f76523d410e077497e6446a105e Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 21 Apr 2021 17:38:46 -0400 Subject: [PATCH] Consider sort direction when resuming (fixes #4909) --- .../java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt index 109732e573..7dd1f653fa 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt @@ -474,7 +474,12 @@ class MangaPresenter( * Returns the next unread chapter or null if everything is read. */ fun getNextUnreadChapter(): ChapterItem? { - return chapters.sortedWith(getChapterSort()).findLast { !it.read } + val chapters = chapters.sortedWith(getChapterSort()) + return if (sortDescending()) { + return chapters.findLast { !it.read } + } else { + chapters.find { !it.read } + } } /**