aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxenofem <xenofem@xeno.science>2020-02-10 09:32:07 -0500
committerxenofem <xenofem@xeno.science>2020-02-10 09:32:07 -0500
commit02864bc07b2ab2f08232ba1c4c27079454dc87ef (patch)
tree809a57a0a19e5c7c294b7d747ee2b441ba8170eb /src
parent44dea9f3646a5c27083dfe6cd6b1522e11c7dc69 (diff)
Prioritize custom emoji a lot and boost exact matches to the top
Diffstat (limited to 'src')
-rw-r--r--src/components/emoji_input/suggestor.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/components/emoji_input/suggestor.js b/src/components/emoji_input/suggestor.js
index 9e437ccc..15a71eff 100644
--- a/src/components/emoji_input/suggestor.js
+++ b/src/components/emoji_input/suggestor.js
@@ -34,7 +34,15 @@ export const suggestEmoji = emojis => input => {
let aScore = 0
let bScore = 0
- // Prioritize emoji that start with the input string
+ // An exact match always wins
+ aScore += a.displayText.toLowerCase() === noPrefix ? 200 : 0
+ bScore += b.displayText.toLowerCase() === noPrefix ? 200 : 0
+
+ // Prioritize custom emoji a lot
+ aScore += a.imageUrl ? 100 : 0
+ bScore += b.imageUrl ? 100 : 0
+
+ // Prioritize prefix matches somewhat
aScore += a.displayText.toLowerCase().startsWith(noPrefix) ? 10 : 0
bScore += b.displayText.toLowerCase().startsWith(noPrefix) ? 10 : 0