File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
app/src/main/java/eu/kanade/tachiyomi/ui/library Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -637,6 +637,9 @@ class LibraryPresenter(
637637 * @param itemList the map to sort.
638638 */
639639 private fun List<LibraryItem>.applySort (): List <LibraryItem > {
640+ // Making sure `allCategories` is stable for `.sort()`Add commentMore actions
641+ val categoryOrderMap = allCategories.associate { it.id to it.order }
642+
640643 val sortFn: (LibraryItem , LibraryItem ) -> Int = { i1, i2 ->
641644 if (i1.header.category.id == i2.header.category.id) {
642645 val category = i1.header.category
@@ -663,12 +666,8 @@ class LibraryPresenter(
663666 LibrarySort .DateAdded -> i2.manga.date_added.compareTo(i1.manga.date_added)
664667 LibrarySort .DragAndDrop -> {
665668 if (category.isDynamic) {
666- val category1 =
667- allCategories.find { i1.manga.category == it.id }?.order
668- ? : 0
669- val category2 =
670- allCategories.find { i2.manga.category == it.id }?.order
671- ? : 0
669+ val category1 = categoryOrderMap[i1.manga.category] ? : 0
670+ val category2 = categoryOrderMap[i2.manga.category] ? : 0
672671 category1.compareTo(category2)
673672 } else {
674673 sortAlphabetical(i1, i2)
You can’t perform that action at this time.
0 commit comments