CommonComposeViewModel: filter all unrelated autocomplete suggestions
This commit is contained in:
parent
3fff54c1f4
commit
629a336e7e
|
@ -267,7 +267,7 @@ public class ComposeAutoCompleteAdapter extends BaseAdapter
|
|||
}
|
||||
|
||||
public final static class AccountResult extends AutocompleteResult {
|
||||
private final Account account;
|
||||
public final Account account;
|
||||
|
||||
public AccountResult(Account account) {
|
||||
this.account = account;
|
||||
|
|
|
@ -252,9 +252,13 @@ open class CommonComposeViewModel(
|
|||
when (token[0]) {
|
||||
'@' -> {
|
||||
return try {
|
||||
api.searchAccounts(query = token.substring(1), limit = 10)
|
||||
val acct = token.substring(1)
|
||||
api.searchAccounts(query = acct, resolve = true, limit = 10)
|
||||
.blockingGet()
|
||||
.map { ComposeAutoCompleteAdapter.AccountResult(it) }
|
||||
.filter {
|
||||
it.account.username.startsWith(acct, ignoreCase = true)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
Log.e(TAG, String.format("Autocomplete search for %s failed.", token), e)
|
||||
emptyList()
|
||||
|
|
Loading…
Reference in New Issue