From 3a8b5e1b5e0a9fdd8b6fd10a23508fb92baf77e2 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 1 Dec 2022 23:00:34 -0500 Subject: [PATCH] Fix default category name being shown with empty library --- .../tachiyomi/ui/library/LibraryScreenModel.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt index c34fd1aedd..1430750250 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryScreenModel.kt @@ -747,10 +747,11 @@ class LibraryScreenModel( val selectionMode = selection.isNotEmpty() val categories = library.keys.toList() + private val onlyDefaultCategory = categories.size == 1 && categories[0].isSystemCategory val libraryCount by lazy { - library - .flatMap { (_, v) -> v } + library.values + .flatten() .fastDistinctBy { it.libraryManga.manga.id } .size } @@ -764,7 +765,7 @@ class LibraryScreenModel( } fun getMangaCountForCategory(category: Category): Int? { - return library[category]?.size?.takeIf { showMangaCount } + return if (showMangaCount) library[category]?.size else null } fun getToolbarTitle( @@ -777,7 +778,11 @@ class LibraryScreenModel( if (it.isSystemCategory) defaultCategoryTitle else it.name } - val title = if (showCategoryTabs && categories.size <= 1) categoryName else defaultTitle + val title = when { + showCategoryTabs && categories.size != 1 -> defaultTitle + libraryCount > 0 && !onlyDefaultCategory -> categoryName + else -> defaultTitle + } val count = when { !showMangaCount -> null !showCategoryTabs -> getMangaCountForCategory(category)