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(
|
combine(
|
||||||
getCategoriesPerLibraryManga.subscribe(),
|
getCategoriesPerLibraryManga.subscribe(),
|
||||||
state.map { it.filterCategory }.distinctUntilChanged(),
|
state.map { it.filterCategory }.distinctUntilChanged(),
|
||||||
::Pair,
|
state.map { it.searchQuery.isNullOrBlank() && !it.hasActiveFilters }.distinctUntilChanged(),
|
||||||
|
::Triple,
|
||||||
),
|
),
|
||||||
// KMK <--
|
// KMK <--
|
||||||
) { (searchQuery, library, _), (tracks, trackingFilter), (groupType, sort), (categoriesPerManga, filterCategory) ->
|
) { (searchQuery, library, _), (tracks, trackingFilter), (groupType, sort), (categoriesPerManga, filterCategory, noActiveFilterOrSearch) ->
|
||||||
library
|
library
|
||||||
// SY -->
|
// SY -->
|
||||||
.applyGrouping(/* KMK --> */ if (filterCategory) LibraryGroup.UNGROUPED else /* KMK <-- */ groupType)
|
.applyGrouping(/* KMK --> */ if (filterCategory) LibraryGroup.UNGROUPED else /* KMK <-- */ groupType)
|
||||||
|
|
@ -238,6 +239,24 @@ class LibraryScreenModel(
|
||||||
value
|
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 {
|
.collectLatest {
|
||||||
mutableState.update { state ->
|
mutableState.update { state ->
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ fun EmptyScreen(
|
||||||
)
|
)
|
||||||
|
|
||||||
// KMK -->
|
// KMK -->
|
||||||
help?.let { help() }
|
help?.invoke()
|
||||||
// KMK <--
|
// KMK <--
|
||||||
|
|
||||||
if (!actions.isNullOrEmpty()) {
|
if (!actions.isNullOrEmpty()) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue