Fix search filters
This commit is contained in:
parent
d565da1492
commit
cc339307bb
@ -262,7 +262,7 @@ class SearchVM : ViewModel(), KoinComponent {
|
||||
) else flowOf(emptyList())
|
||||
searchService.search(
|
||||
query,
|
||||
filters = if (query.isEmpty()) filters.copy(apps = true) else filters,
|
||||
filters = filters,
|
||||
previousResults,
|
||||
)
|
||||
.combine(hiddenItemKeys) { results, hiddenKeys -> results to hiddenKeys }
|
||||
@ -440,11 +440,13 @@ class SearchVM : ViewModel(), KoinComponent {
|
||||
add(item)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun <T : SavableSearchable> SnapshotStateList<T>.mergeWith(
|
||||
newItems: List<T>?,
|
||||
hiddenKeys: List<String>,
|
||||
query: String
|
||||
) = this.mergeWith((newItems ?: emptyList()).filterNot { hiddenKeys.contains(it.key) }.applyRanking(query))
|
||||
) = this.mergeWith((newItems ?: emptyList()).filterNot { hiddenKeys.contains(it.key) }
|
||||
.applyRanking(query))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -58,7 +58,21 @@ internal class SearchServiceImpl(
|
||||
initialResults: SearchResults?,
|
||||
): Flow<SearchResults> = flow {
|
||||
supervisorScope {
|
||||
val results = MutableStateFlow(initialResults ?: SearchResults())
|
||||
val results = MutableStateFlow(
|
||||
initialResults?.let {
|
||||
it.copy(
|
||||
apps = if (filters.apps) it.apps else null,
|
||||
shortcuts = if (filters.shortcuts) it.shortcuts else null,
|
||||
contacts = if (filters.contacts) it.contacts else null,
|
||||
calendars = if (filters.events) it.calendars else null,
|
||||
files = if (filters.files) it.files else null,
|
||||
calculators = if (filters.tools) it.calculators else null,
|
||||
unitConverters = if (filters.tools) it.unitConverters else null,
|
||||
websites = if (filters.websites) it.websites else null,
|
||||
wikipedia = if (filters.articles) it.wikipedia else null,
|
||||
)
|
||||
}
|
||||
?: SearchResults())
|
||||
|
||||
val customAttrResults = customAttributesRepository.search(query)
|
||||
.map { items ->
|
||||
@ -268,11 +282,23 @@ internal class SearchServiceImpl(
|
||||
val privateSpaceApps = mutableListOf<Application>()
|
||||
for (app in apps) {
|
||||
when {
|
||||
standardProfile != null && app.user == standardProfile.userHandle -> standardProfileApps.add(app)
|
||||
workProfile != null && app.user == workProfile.userHandle -> workProfileApps.add(app)
|
||||
privateSpace != null && app.user == privateSpace.userHandle -> privateSpaceApps.add(app)
|
||||
standardProfile != null && app.user == standardProfile.userHandle -> standardProfileApps.add(
|
||||
app
|
||||
)
|
||||
|
||||
workProfile != null && app.user == workProfile.userHandle -> workProfileApps.add(
|
||||
app
|
||||
)
|
||||
|
||||
privateSpace != null && app.user == privateSpace.userHandle -> privateSpaceApps.add(
|
||||
app
|
||||
)
|
||||
|
||||
else -> {
|
||||
Log.w("MM20", "App ${app.label} does not belong to any known profile. Ignoring.")
|
||||
Log.w(
|
||||
"MM20",
|
||||
"App ${app.label} does not belong to any known profile. Ignoring."
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user