perf: search ignoreCase (#579)

This commit is contained in:
lisonge 2024-03-30 22:53:08 +08:00
parent 679513b1aa
commit 517bfb49fe
2 changed files with 11 additions and 5 deletions

View File

@ -77,7 +77,12 @@ class GlobalRuleExcludeVm @Inject constructor(stateHandle: SavedStateHandle) : V
if (str.isBlank()) {
apps
} else {
(apps.filter { a -> a.name.contains(str) } + apps.filter { a -> a.id.contains(str) }).distinct()
(apps.filter { a -> a.name.contains(str, true) } + apps.filter { a ->
a.id.contains(
str,
true
)
}).distinct()
}
}.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())

View File

@ -202,13 +202,14 @@ class HomeVm @Inject constructor() : ViewModel() {
appInfos
}
}
}.combine(debounceSearchStrFlow) { appInfos, debounceSearchStr ->
if (debounceSearchStr.isBlank()) {
}.combine(debounceSearchStrFlow) { appInfos, str ->
if (str.isBlank()) {
appInfos
} else {
(appInfos.filter { a -> a.name.contains(debounceSearchStr) } + appInfos.filter { a ->
(appInfos.filter { a -> a.name.contains(str, true) } + appInfos.filter { a ->
a.id.contains(
debounceSearchStr
str,
true
)
}).distinct()
}