Improve algo
This commit is contained in:
parent
c5739abe32
commit
c992d32afd
|
@ -102,7 +102,7 @@ class TextComposerViewModel @AssistedInject constructor(@Assisted initialState:
|
||||||
users
|
users
|
||||||
} else {
|
} else {
|
||||||
users.filter {
|
users.filter {
|
||||||
it.displayName?.startsWith(prefix = filter, ignoreCase = true) ?: false
|
it.displayName?.contains(filter, ignoreCase = true) ?: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.sortedBy { it.displayName }
|
.sortedBy { it.displayName }
|
||||||
|
@ -139,11 +139,15 @@ class TextComposerViewModel @AssistedInject constructor(@Assisted initialState:
|
||||||
session.rx().liveGroupSummaries(),
|
session.rx().liveGroupSummaries(),
|
||||||
groupsQueryObservable.throttleLast(300, TimeUnit.MILLISECONDS),
|
groupsQueryObservable.throttleLast(300, TimeUnit.MILLISECONDS),
|
||||||
BiFunction { groupSummaries, query ->
|
BiFunction { groupSummaries, query ->
|
||||||
val filter = query.orNull() ?: ""
|
val filter = query.orNull()
|
||||||
|
if (filter.isNullOrBlank()) {
|
||||||
|
groupSummaries
|
||||||
|
} else {
|
||||||
groupSummaries
|
groupSummaries
|
||||||
.filter {
|
.filter {
|
||||||
it.groupId.contains(filter, ignoreCase = true)
|
it.groupId.contains(filter, ignoreCase = true)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.sortedBy { it.displayName }
|
.sortedBy { it.displayName }
|
||||||
}
|
}
|
||||||
).execute { async ->
|
).execute { async ->
|
||||||
|
|
Loading…
Reference in New Issue