mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-25 02:18:24 +01:00
Show unread entries first when sorting by unread (closes #4711)
Based on b212f8233e
This commit is contained in:
parent
e5a120e778
commit
a16240f123
@ -236,6 +236,7 @@ class LibraryPresenter(
|
|||||||
db.getLatestChapterManga().executeAsBlocking().associate { it.id!! to counter++ }
|
db.getLatestChapterManga().executeAsBlocking().associate { it.id!! to counter++ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val sortAscending = preferences.librarySortingAscending().get()
|
||||||
val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
|
val sortFn: (LibraryItem, LibraryItem) -> Int = { i1, i2 ->
|
||||||
when (sortingMode) {
|
when (sortingMode) {
|
||||||
LibrarySort.ALPHA -> i1.manga.title.compareTo(i2.manga.title, true)
|
LibrarySort.ALPHA -> i1.manga.title.compareTo(i2.manga.title, true)
|
||||||
@ -246,7 +247,13 @@ class LibraryPresenter(
|
|||||||
manga1LastRead.compareTo(manga2LastRead)
|
manga1LastRead.compareTo(manga2LastRead)
|
||||||
}
|
}
|
||||||
LibrarySort.LAST_CHECKED -> i2.manga.last_update.compareTo(i1.manga.last_update)
|
LibrarySort.LAST_CHECKED -> i2.manga.last_update.compareTo(i1.manga.last_update)
|
||||||
LibrarySort.UNREAD -> i1.manga.unread.compareTo(i2.manga.unread)
|
LibrarySort.UNREAD -> when {
|
||||||
|
// Ensure unread content comes first
|
||||||
|
i1.manga.unread == i2.manga.unread -> 0
|
||||||
|
i1.manga.unread == 0 -> if (sortAscending) 1 else -1
|
||||||
|
i2.manga.unread == 0 -> if (sortAscending) -1 else 1
|
||||||
|
else -> i1.manga.unread.compareTo(i2.manga.unread)
|
||||||
|
}
|
||||||
LibrarySort.TOTAL -> {
|
LibrarySort.TOTAL -> {
|
||||||
val manga1TotalChapter = totalChapterManga[i1.manga.id!!] ?: 0
|
val manga1TotalChapter = totalChapterManga[i1.manga.id!!] ?: 0
|
||||||
val mange2TotalChapter = totalChapterManga[i2.manga.id!!] ?: 0
|
val mange2TotalChapter = totalChapterManga[i2.manga.id!!] ?: 0
|
||||||
@ -264,7 +271,7 @@ class LibraryPresenter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val comparator = if (preferences.librarySortingAscending().get()) {
|
val comparator = if (sortAscending) {
|
||||||
Comparator(sortFn)
|
Comparator(sortFn)
|
||||||
} else {
|
} else {
|
||||||
Collections.reverseOrder(sortFn)
|
Collections.reverseOrder(sortFn)
|
||||||
|
Loading…
Reference in New Issue
Block a user