parent
80c4fcce82
commit
0f71d61b88
|
@ -256,13 +256,19 @@ struct ComposeAutocompleteEmojisView: View {
|
|||
}
|
||||
|
||||
mastodonController.getCustomEmojis { (emojis) in
|
||||
self.emojis =
|
||||
let emojis: [Emoji] =
|
||||
emojis.map { (emoji) -> (Emoji, (matched: Bool, score: Int)) in
|
||||
(emoji, FuzzyMatcher.match(pattern: query, str: emoji.shortcode))
|
||||
}
|
||||
.filter(\.1.matched)
|
||||
.sorted { $0.1.score > $1.1.score }
|
||||
.map(\.0)
|
||||
var shortcodes = Set<String>()
|
||||
self.emojis = []
|
||||
for emoji in emojis where !shortcodes.contains(emoji.shortcode) {
|
||||
self.emojis.append(emoji)
|
||||
shortcodes.insert(emoji.shortcode)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue