mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-18 04:08:44 +03:00
Move comment
This commit is contained in:
parent
92d7ebe94f
commit
9ecceafb96
2 changed files with 3 additions and 2 deletions
|
@ -59,8 +59,6 @@ class EmojiSearchResultViewModel @AssistedInject constructor(
|
|||
setState {
|
||||
copy(
|
||||
query = action.queryString,
|
||||
// First add emojis with name matching query, sorted by name
|
||||
// Then emojis with keyword matching any of the word in the query, sorted by name
|
||||
results = dataSource.filterWith(action.queryString)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -37,11 +37,13 @@ class EmojiDataSource @Inject constructor(
|
|||
fun filterWith(query: String): List<EmojiItem> {
|
||||
val words = query.split("\\s".toRegex())
|
||||
|
||||
// First add emojis with name matching query, sorted by name
|
||||
return (rawData.emojis.values
|
||||
.filter { emojiItem ->
|
||||
emojiItem.name.contains(query, true)
|
||||
}
|
||||
.sortedBy { it.name } +
|
||||
// Then emojis with keyword matching any of the word in the query, sorted by name
|
||||
rawData.emojis.values
|
||||
.filter { emojiItem ->
|
||||
words.fold(true, { prev, word ->
|
||||
|
@ -49,6 +51,7 @@ class EmojiDataSource @Inject constructor(
|
|||
})
|
||||
}
|
||||
.sortedBy { it.name })
|
||||
// and ensure they will not be present twice
|
||||
.distinct()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue