mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-09-13 14:27:17 +00:00
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:
parent
f1cfd152e2
commit
da635229bf
6 changed files with 10 additions and 13 deletions
|
@ -31,7 +31,7 @@ var UI = struct {
|
|||
Reactions []string
|
||||
ReactionsLookup container.Set[string] `ini:"-"`
|
||||
CustomEmojis []string
|
||||
CustomEmojisMap map[string]string `ini:"-"`
|
||||
CustomEmojisLookup container.Set[string] `ini:"-"`
|
||||
SearchRepoDescription bool
|
||||
OnlyShowRelevantRepos bool
|
||||
ExploreDefaultSort string `ini:"EXPLORE_PAGING_DEFAULT_SORT"`
|
||||
|
@ -87,7 +87,6 @@ var UI = struct {
|
|||
Themes: []string{`forgejo-auto`, `forgejo-light`, `forgejo-dark`, `gitea-auto`, `gitea-light`, `gitea-dark`, `forgejo-auto-deuteranopia-protanopia`, `forgejo-light-deuteranopia-protanopia`, `forgejo-dark-deuteranopia-protanopia`, `forgejo-auto-tritanopia`, `forgejo-light-tritanopia`, `forgejo-dark-tritanopia`},
|
||||
Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`},
|
||||
CustomEmojis: []string{`git`, `gitea`, `codeberg`, `gitlab`, `github`, `gogs`, `forgejo`},
|
||||
CustomEmojisMap: map[string]string{"git": ":git:", "gitea": ":gitea:", "codeberg": ":codeberg:", "gitlab": ":gitlab:", "github": ":github:", "gogs": ":gogs:", "forgejo": ":forgejo:"},
|
||||
ExploreDefaultSort: "recentupdate",
|
||||
PreferredTimestampTense: "mixed",
|
||||
|
||||
|
@ -163,8 +162,6 @@ func loadUIFrom(rootCfg ConfigProvider) {
|
|||
for _, reaction := range UI.Reactions {
|
||||
UI.ReactionsLookup.Add(reaction)
|
||||
}
|
||||
UI.CustomEmojisMap = make(map[string]string)
|
||||
for _, emoji := range UI.CustomEmojis {
|
||||
UI.CustomEmojisMap[emoji] = ":" + emoji + ":"
|
||||
}
|
||||
UI.CustomEmojisLookup = make(container.Set[string])
|
||||
UI.CustomEmojisLookup.AddMultiple(UI.CustomEmojis...)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue