feat(library): Hide empty library tabs when searching/filtering (#1069)
* feat(library): Hide empty library tabs when searching/filtering * Add search-global to Empty screen in Library * Simplify conditional logic * combine conditional flow * Optimize code * Simplified the code * Simplified the code
This commit is contained in:
parent
e9437d6674
commit
0d34d2f8bc
2 changed files with 22 additions and 3 deletions
|
|
@ -205,10 +205,11 @@ class LibraryScreenModel(
|
|||
combine(
|
||||
getCategoriesPerLibraryManga.subscribe(),
|
||||
state.map { it.filterCategory }.distinctUntilChanged(),
|
||||
::Pair,
|
||||
state.map { it.searchQuery.isNullOrBlank() && !it.hasActiveFilters }.distinctUntilChanged(),
|
||||
::Triple,
|
||||
),
|
||||
// KMK <--
|
||||
) { (searchQuery, library, _), (tracks, trackingFilter), (groupType, sort), (categoriesPerManga, filterCategory) ->
|
||||
) { (searchQuery, library, _), (tracks, trackingFilter), (groupType, sort), (categoriesPerManga, filterCategory, noActiveFilterOrSearch) ->
|
||||
library
|
||||
// SY -->
|
||||
.applyGrouping(/* KMK --> */ if (filterCategory) LibraryGroup.UNGROUPED else /* KMK <-- */ groupType)
|
||||
|
|
@ -238,6 +239,24 @@ class LibraryScreenModel(
|
|||
value
|
||||
}
|
||||
}
|
||||
// KMK -->
|
||||
.filter {
|
||||
noActiveFilterOrSearch || it.value.isNotEmpty()
|
||||
}
|
||||
.let {
|
||||
it.ifEmpty {
|
||||
mapOf(
|
||||
Category(
|
||||
0,
|
||||
preferences.context.stringResource(MR.strings.default_category),
|
||||
0,
|
||||
0,
|
||||
false,
|
||||
) to emptyList(),
|
||||
)
|
||||
}
|
||||
}
|
||||
// KMK <--
|
||||
}
|
||||
.collectLatest {
|
||||
mutableState.update { state ->
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ fun EmptyScreen(
|
|||
)
|
||||
|
||||
// KMK -->
|
||||
help?.let { help() }
|
||||
help?.invoke()
|
||||
// KMK <--
|
||||
|
||||
if (!actions.isNullOrEmpty()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue