chore: simplify storing and sending custom emoji's

- Using a map to store the CustomEmojis is unncessary, the values can be
derived by the key easily. We still need to know if a certain name is
custom emoji, so store the custom emojis in a `Set`.
- Instead of constructing a map in `window.config`, construct a `Set`
and reconstruct the value in `emoji.js`. This has the main benefit of
reducing the amount of text being sent for each request, which is quite
noticable if a Forgejo instance has many (>1000) custom emojis.
- Remove the default value of `CustomEmojisMap`, it will be constructed anyway.
This commit is contained in:
Gusted 2025-08-10 21:36:11 +02:00
commit da635229bf
No known key found for this signature in database
GPG key ID: FD821B732837125F
6 changed files with 10 additions and 13 deletions

View file

@ -1142,7 +1142,7 @@ func emojiShortCodeProcessor(ctx *RenderContext, node *html.Node) {
converted := emoji.FromAlias(alias)
if converted == nil {
// check if this is a custom reaction
if _, exist := setting.UI.CustomEmojisMap[alias]; exist {
if setting.UI.CustomEmojisLookup.Contains(alias) {
replaceContent(node, m[0], m[1], createCustomEmoji(alias))
node = node.NextSibling.NextSibling
start = 0