mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 18:08:24 +01:00
Added missing sorting cases handling
Previous commit missed some cases resulting in errors at runtime
This commit is contained in:
parent
ee8c71c14a
commit
9e830f1c55
@ -35,3 +35,12 @@ class ChapterLoadByNumber {
|
|||||||
return chapters.sortedBy { it.chapter_number }
|
return chapters.sortedBy { it.chapter_number }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load strategy using the chapter upload date. This ordering ignores scanlators
|
||||||
|
*/
|
||||||
|
class ChapterLoadByUploadDate() {
|
||||||
|
fun get(allChapters: List<Chapter>): List<Chapter> {
|
||||||
|
return allChapters.sortedBy { it.date_upload }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -129,6 +129,7 @@ class ReaderPresenter(
|
|||||||
when (manga.sorting) {
|
when (manga.sorting) {
|
||||||
Manga.SORTING_SOURCE -> ChapterLoadBySource().get(chaptersForReader)
|
Manga.SORTING_SOURCE -> ChapterLoadBySource().get(chaptersForReader)
|
||||||
Manga.SORTING_NUMBER -> ChapterLoadByNumber().get(chaptersForReader, selectedChapter)
|
Manga.SORTING_NUMBER -> ChapterLoadByNumber().get(chaptersForReader, selectedChapter)
|
||||||
|
Manga.SORTING_UPLOAD_DATE -> ChapterLoadByUploadDate().get(chaptersForReader)
|
||||||
else -> error("Unknown sorting method")
|
else -> error("Unknown sorting method")
|
||||||
}.map(::ReaderChapter)
|
}.map(::ReaderChapter)
|
||||||
}
|
}
|
||||||
|
@ -98,6 +98,7 @@ class HistoryPresenter : BasePresenter<HistoryController>() {
|
|||||||
val sortFunction: (Chapter, Chapter) -> Int = when (manga.sorting) {
|
val sortFunction: (Chapter, Chapter) -> Int = when (manga.sorting) {
|
||||||
Manga.SORTING_SOURCE -> { c1, c2 -> c2.source_order.compareTo(c1.source_order) }
|
Manga.SORTING_SOURCE -> { c1, c2 -> c2.source_order.compareTo(c1.source_order) }
|
||||||
Manga.SORTING_NUMBER -> { c1, c2 -> c1.chapter_number.compareTo(c2.chapter_number) }
|
Manga.SORTING_NUMBER -> { c1, c2 -> c1.chapter_number.compareTo(c2.chapter_number) }
|
||||||
|
Manga.SORTING_UPLOAD_DATE -> { c1, c2 -> c1.date_upload.compareTo(c2.date_upload) }
|
||||||
else -> throw NotImplementedError("Unknown sorting method")
|
else -> throw NotImplementedError("Unknown sorting method")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +118,12 @@ class HistoryPresenter : BasePresenter<HistoryController>() {
|
|||||||
it.chapter_number <= chapterNumber + 1
|
it.chapter_number <= chapterNumber + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Manga.SORTING_UPLOAD_DATE -> {
|
||||||
|
val dateUpload = chapter.date_upload
|
||||||
|
((currChapterIndex + 1) until chapters.size)
|
||||||
|
.map { chapters[it] }
|
||||||
|
.firstOrNull { it.date_upload > dateUpload }
|
||||||
|
}
|
||||||
else -> throw NotImplementedError("Unknown sorting method")
|
else -> throw NotImplementedError("Unknown sorting method")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user