fix(library): Include default category in allCategories

This commit is contained in:
Ahmad Ansori Palembani 2024-12-08 09:37:10 +07:00
parent d7c3aa6b45
commit 349b9c181a
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6

View file

@ -818,16 +818,20 @@ class LibraryPresenter(
getPreferencesFlow(), getPreferencesFlow(),
preferences.removeArticles().changes(), preferences.removeArticles().changes(),
fetchLibrary fetchLibrary
) { allCategories, libraryMangaList, prefs, removeArticles, _ -> ) { dbCategories, libraryMangaList, prefs, removeArticles, _ ->
groupType = prefs.groupType groupType = prefs.groupType
val defaultCategory = createDefaultCategory()
val allCategories = listOf(defaultCategory) + dbCategories
val (items, categories, hiddenItems) = if (groupType <= BY_DEFAULT || !libraryIsGrouped) { val (items, categories, hiddenItems) = if (groupType <= BY_DEFAULT || !libraryIsGrouped) {
getLibraryItems( getLibraryItems(
allCategories, dbCategories,
libraryMangaList, libraryMangaList,
prefs.sortingMode, prefs.sortingMode,
prefs.sortAscending, prefs.sortAscending,
prefs.showAllCategories, prefs.showAllCategories,
defaultCategory,
) )
} else { } else {
getDynamicLibraryItems( getDynamicLibraryItems(
@ -854,6 +858,7 @@ class LibraryPresenter(
sortingMode: Int, sortingMode: Int,
isAscending: Boolean, isAscending: Boolean,
showAll: Boolean, showAll: Boolean,
defaultCategory: Category,
): Triple<List<LibraryItem>, List<Category>, List<LibraryItem>> { ): Triple<List<LibraryItem>, List<Category>, List<LibraryItem>> {
val categories = allCategories.toMutableList() val categories = allCategories.toMutableList()
val hiddenItems = mutableListOf<LibraryItem>() val hiddenItems = mutableListOf<LibraryItem>()
@ -898,7 +903,7 @@ class LibraryPresenter(
preferences.collapsedCategories().get().mapNotNull { it.toIntOrNull() }.toSet() preferences.collapsedCategories().get().mapNotNull { it.toIntOrNull() }.toSet()
} }
if (categorySet.contains(0)) categories.add(0, createDefaultCategory()) if (categorySet.contains(0)) categories.add(0, defaultCategory)
if (libraryIsGrouped) { if (libraryIsGrouped) {
categories.forEach { category -> categories.forEach { category ->
val catId = category.id ?: return@forEach val catId = category.id ?: return@forEach