Ensure there is never twice the same emoji

This commit is contained in:
Benoit Marty 2019-12-22 08:36:54 +01:00
parent 8b4c51139d
commit 9e73e95f55
1 changed files with 3 additions and 2 deletions

View File

@ -37,7 +37,7 @@ class EmojiDataSource @Inject constructor(
fun filterWith(query: String): List<EmojiItem> { fun filterWith(query: String): List<EmojiItem> {
val words = query.split("\\s".toRegex()) val words = query.split("\\s".toRegex())
return rawData.emojis.values return (rawData.emojis.values
.filter { emojiItem -> .filter { emojiItem ->
emojiItem.name.contains(query, true) emojiItem.name.contains(query, true)
} }
@ -48,7 +48,8 @@ class EmojiDataSource @Inject constructor(
prev && emojiItem.keywords.any { keyword -> keyword.contains(word, true) } prev && emojiItem.keywords.any { keyword -> keyword.contains(word, true) }
}) })
} }
.sortedBy { it.name } .sortedBy { it.name })
.distinct()
} }
fun getQuickReactions(): List<EmojiItem> { fun getQuickReactions(): List<EmojiItem> {