Fix default category name being shown with empty library
(cherry picked from commit 3a8b5e1b5e0a9fdd8b6fd10a23508fb92baf77e2)
This commit is contained in:
parent
6579dddd87
commit
e7824a6891
@ -1312,10 +1312,11 @@ class LibraryScreenModel(
|
|||||||
val selectionMode = selection.isNotEmpty()
|
val selectionMode = selection.isNotEmpty()
|
||||||
|
|
||||||
val categories = library.keys.toList()
|
val categories = library.keys.toList()
|
||||||
|
private val onlyDefaultCategory = categories.size == 1 && categories[0].isSystemCategory
|
||||||
|
|
||||||
val libraryCount by lazy {
|
val libraryCount by lazy {
|
||||||
library
|
library.values
|
||||||
.flatMap { (_, v) -> v }
|
.flatten()
|
||||||
.fastDistinctBy { it.libraryManga.manga.id }
|
.fastDistinctBy { it.libraryManga.manga.id }
|
||||||
.size
|
.size
|
||||||
}
|
}
|
||||||
@ -1342,7 +1343,7 @@ class LibraryScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getMangaCountForCategory(category: Category): Int? {
|
fun getMangaCountForCategory(category: Category): Int? {
|
||||||
return library[category]?.size?.takeIf { showMangaCount }
|
return if (showMangaCount) library[category]?.size else null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getToolbarTitle(
|
fun getToolbarTitle(
|
||||||
@ -1355,7 +1356,11 @@ class LibraryScreenModel(
|
|||||||
if (it.isSystemCategory) defaultCategoryTitle else it.name
|
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 {
|
val count = when {
|
||||||
!showMangaCount -> null
|
!showMangaCount -> null
|
||||||
!showCategoryTabs -> getMangaCountForCategory(category)
|
!showCategoryTabs -> getMangaCountForCategory(category)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user