Fix search filters
This commit is contained in:
parent
d565da1492
commit
cc339307bb
@ -262,7 +262,7 @@ class SearchVM : ViewModel(), KoinComponent {
|
|||||||
) else flowOf(emptyList())
|
) else flowOf(emptyList())
|
||||||
searchService.search(
|
searchService.search(
|
||||||
query,
|
query,
|
||||||
filters = if (query.isEmpty()) filters.copy(apps = true) else filters,
|
filters = filters,
|
||||||
previousResults,
|
previousResults,
|
||||||
)
|
)
|
||||||
.combine(hiddenItemKeys) { results, hiddenKeys -> results to hiddenKeys }
|
.combine(hiddenItemKeys) { results, hiddenKeys -> results to hiddenKeys }
|
||||||
@ -440,11 +440,13 @@ class SearchVM : ViewModel(), KoinComponent {
|
|||||||
add(item)
|
add(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun <T : SavableSearchable> SnapshotStateList<T>.mergeWith(
|
private suspend fun <T : SavableSearchable> SnapshotStateList<T>.mergeWith(
|
||||||
newItems: List<T>?,
|
newItems: List<T>?,
|
||||||
hiddenKeys: List<String>,
|
hiddenKeys: List<String>,
|
||||||
query: 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?,
|
initialResults: SearchResults?,
|
||||||
): Flow<SearchResults> = flow {
|
): Flow<SearchResults> = flow {
|
||||||
supervisorScope {
|
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)
|
val customAttrResults = customAttributesRepository.search(query)
|
||||||
.map { items ->
|
.map { items ->
|
||||||
@ -266,13 +280,25 @@ internal class SearchServiceImpl(
|
|||||||
val standardProfileApps = mutableListOf<Application>()
|
val standardProfileApps = mutableListOf<Application>()
|
||||||
val workProfileApps = mutableListOf<Application>()
|
val workProfileApps = mutableListOf<Application>()
|
||||||
val privateSpaceApps = mutableListOf<Application>()
|
val privateSpaceApps = mutableListOf<Application>()
|
||||||
for (app in apps) {
|
for (app in apps) {
|
||||||
when {
|
when {
|
||||||
standardProfile != null && app.user == standardProfile.userHandle -> standardProfileApps.add(app)
|
standardProfile != null && app.user == standardProfile.userHandle -> standardProfileApps.add(
|
||||||
workProfile != null && app.user == workProfile.userHandle -> workProfileApps.add(app)
|
app
|
||||||
privateSpace != null && app.user == privateSpace.userHandle -> privateSpaceApps.add(app)
|
)
|
||||||
|
|
||||||
|
workProfile != null && app.user == workProfile.userHandle -> workProfileApps.add(
|
||||||
|
app
|
||||||
|
)
|
||||||
|
|
||||||
|
privateSpace != null && app.user == privateSpace.userHandle -> privateSpaceApps.add(
|
||||||
|
app
|
||||||
|
)
|
||||||
|
|
||||||
else -> {
|
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