From 51c93bcd55609e96de58c15a53d54566788d6cd8 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 11 May 2020 13:01:54 -0400 Subject: [PATCH] Fixed being able to collaspe catrgories if you only have one --- .../kanade/tachiyomi/ui/library/LibraryPresenter.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index 0818cd4d48..88f12ff3bf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -125,7 +125,8 @@ class LibraryPresenter( fun restoreLibrary() { val items = libraryItems - val show = showAllCategories || preferences.hideCategories().getOrDefault() + val show = showAllCategories || preferences.hideCategories().getOrDefault() || + categories.size == 1 if (!show) { sectionedLibraryItems = items.groupBy { it.manga.category }.toMutableMap() if (currentCategory == -1) currentCategory = categories.find { @@ -141,8 +142,9 @@ class LibraryPresenter( private suspend fun sectionLibrary(items: List, freshStart: Boolean = false) { libraryItems = items - val show = showAllCategories || preferences.hideCategories().getOrDefault() - if (!show) { + val showAll = showAllCategories || preferences.hideCategories().getOrDefault() || + categories.size == 1 + if (!showAll) { sectionedLibraryItems = items.groupBy { it.manga.category }.toMutableMap() if (currentCategory == -1) currentCategory = categories.find { it.order == preferences.lastUsedCategory().getOrDefault() @@ -150,7 +152,7 @@ class LibraryPresenter( } withContext(Dispatchers.Main) { view.onNextLibraryUpdate( - if (!show) sectionedLibraryItems[currentCategory] + if (!showAll) sectionedLibraryItems[currentCategory] ?: sectionedLibraryItems[categories.first().id] ?: blankItem() else libraryItems, freshStart ) @@ -530,7 +532,7 @@ class LibraryPresenter( if (headerItem != null) items.add( LibraryItem(LibraryManga.createBlank(catId), headerItem) ) - } else if (catId in categoriesHidden && showAll) { + } else if (catId in categoriesHidden && showAll && categories.size > 1) { val mangaToRemove = items.filter { it.manga.category == catId } val mergedTitle = mangaToRemove.joinToString("-") { it.manga.title + "-" + it.manga.author