Consider sort direction when resuming (fixes #4909)

(cherry picked from commit 8882cd4787040f76523d410e077497e6446a105e)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt
This commit is contained in:
arkon 2021-04-21 17:38:46 -04:00 committed by Jobobby04
parent 3104f3a8b5
commit 80a5a54e60

View File

@ -891,10 +891,19 @@ class MangaPresenter(
* Returns the next unread chapter or null if everything is read.
*/
fun getNextUnreadChapter(): ChapterItem? {
val chapters = chapters.sortedWith(getChapterSort())
return if (source.isEhBasedSource()) {
chapters.sortedWith(getChapterSort()).firstOrNull()?.takeUnless { it.read }
if (sortDescending()) {
chapters.firstOrNull()?.takeUnless { it.read }
} else {
chapters.lastOrNull()?.takeUnless { it.read }
}
} else {
chapters.sortedWith(getChapterSort()).findLast { !it.read }
if (sortDescending()) {
return chapters.findLast { !it.read }
} else {
chapters.find { !it.read }
}
}
}