Improve library performance a bit

This commit is contained in:
Jobobby04 2022-01-16 15:05:44 -05:00
parent ecc708b6cd
commit 29241b0393

View File

@ -485,15 +485,17 @@ class LibraryPresenter(
private fun applyGrouping(map: LibraryMap, categories: List<Category>): Pair<LibraryMap, List<Category>> {
groupType = preferences.groupLibraryBy().get()
var editedCategories = categories
val libraryMangaAsList = map.flatMap { it.value }.distinctBy { it.manga.id }
val items = if (groupType == LibraryGroup.BY_DEFAULT) {
map
} else if (!libraryIsGrouped) {
editedCategories = listOf(Category.create("All").apply { this.id = 0 })
libraryMangaAsList
.groupBy { 0 }
mapOf(
0 to map.values.flatten().distinctBy { it.manga.id }
)
} else {
val (items, customCategories) = getGroupedMangaItems(libraryMangaAsList)
val (items, customCategories) = getGroupedMangaItems(
map.values.flatten().distinctBy { it.manga.id }
)
editedCategories = customCategories
items
}