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()) { if (str.isBlank()) {
apps apps
} else { } 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()) }.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())

View File

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