forked from AkkomaGang/akkoma-fe
Prioritize custom emoji a lot and boost exact matches to the top
This commit is contained in:
parent
44dea9f364
commit
02864bc07b
1 changed files with 9 additions and 1 deletions
|
@ -34,7 +34,15 @@ export const suggestEmoji = emojis => input => {
|
||||||
let aScore = 0
|
let aScore = 0
|
||||||
let bScore = 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
|
aScore += a.displayText.toLowerCase().startsWith(noPrefix) ? 10 : 0
|
||||||
bScore += b.displayText.toLowerCase().startsWith(noPrefix) ? 10 : 0
|
bScore += b.displayText.toLowerCase().startsWith(noPrefix) ? 10 : 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue