Improve algo

This commit is contained in:
Benoit Marty 2019-12-20 10:23:45 +01:00
parent c5739abe32
commit c992d32afd
1 changed files with 10 additions and 6 deletions

View File

@ -102,7 +102,7 @@ class TextComposerViewModel @AssistedInject constructor(@Assisted initialState:
users
} else {
users.filter {
it.displayName?.startsWith(prefix = filter, ignoreCase = true) ?: false
it.displayName?.contains(filter, ignoreCase = true) ?: false
}
}
.sortedBy { it.displayName }
@ -139,11 +139,15 @@ class TextComposerViewModel @AssistedInject constructor(@Assisted initialState:
session.rx().liveGroupSummaries(),
groupsQueryObservable.throttleLast(300, TimeUnit.MILLISECONDS),
BiFunction { groupSummaries, query ->
val filter = query.orNull() ?: ""
groupSummaries
.filter {
it.groupId.contains(filter, ignoreCase = true)
}
val filter = query.orNull()
if (filter.isNullOrBlank()) {
groupSummaries
} else {
groupSummaries
.filter {
it.groupId.contains(filter, ignoreCase = true)
}
}
.sortedBy { it.displayName }
}
).execute { async ->