Skip to content

Commit

Permalink
Bug fix: Correctly use stable ids in EmojiAdapter to prevent showing …
Browse files Browse the repository at this point in the history
…the same Emoji multiple times. (#1040)
  • Loading branch information
vanniktech authored Dec 10, 2023
1 parent 67b99ce commit 23f5e0c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ internal class EmojiAdapter(
setHasStableIds(true)
}

override fun getItemId(position: Int) = items[position].emoji.hashCode().toLong()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = EmojiViewHolder(parent)

override fun onBindViewHolder(holder: EmojiViewHolder, position: Int) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SearchEmojiManager : SearchEmoji {
return when {
query.length > 1 -> categories.flatMap { it.emojis.toList() }
.mapNotNull { emoji ->
emoji.shortcodes.mapNotNull { shortcode ->
emoji.shortcodes.firstNotNullOfOrNull { shortcode ->
val index = shortcode.indexOf(query, ignoreCase = true)

if (index >= 0) {
Expand All @@ -37,7 +37,7 @@ class SearchEmojiManager : SearchEmoji {
} else {
null
}
}.firstOrNull()
}
}
else -> emptyList()
}
Expand Down

0 comments on commit 23f5e0c

Please sign in to comment.