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:
parent
3104f3a8b5
commit
80a5a54e60
@ -891,10 +891,19 @@ class MangaPresenter(
|
|||||||
* Returns the next unread chapter or null if everything is read.
|
* Returns the next unread chapter or null if everything is read.
|
||||||
*/
|
*/
|
||||||
fun getNextUnreadChapter(): ChapterItem? {
|
fun getNextUnreadChapter(): ChapterItem? {
|
||||||
|
val chapters = chapters.sortedWith(getChapterSort())
|
||||||
return if (source.isEhBasedSource()) {
|
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 {
|
} else {
|
||||||
chapters.sortedWith(getChapterSort()).findLast { !it.read }
|
if (sortDescending()) {
|
||||||
|
return chapters.findLast { !it.read }
|
||||||
|
} else {
|
||||||
|
chapters.find { !it.read }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user