diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-08-12 16:36:23 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-12 08:36:23 +0000 |
commit | 74930b1ccd9acacd1ddaa30d1b4849b0e4570d7c (patch) | |
tree | c67b4878f2bf7b47278283be4e9cd6f73ed7990d /web_src/js | |
parent | 2fc0eb913caf40aec056d49f5838992e136208a2 (diff) | |
download | gitea-74930b1ccd9acacd1ddaa30d1b4849b0e4570d7c.tar.gz gitea-74930b1ccd9acacd1ddaa30d1b4849b0e4570d7c.zip |
Avoiding accessing undefined mentionValues (#26461)
The `window.config.mentionValues` might be undefined:
```
{{if or .Participants .Assignees .MentionableTeams}}
mentionValues: ...
{{end}}
```
Diffstat (limited to 'web_src/js')
-rw-r--r-- | web_src/js/features/tribute.js | 2 | ||||
-rw-r--r-- | web_src/js/utils/match.js | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/web_src/js/features/tribute.js b/web_src/js/features/tribute.js index 43fa79b2a4..055777be79 100644 --- a/web_src/js/features/tribute.js +++ b/web_src/js/features/tribute.js @@ -31,7 +31,7 @@ function makeCollections({mentions, emoji}) { if (mentions) { collections.push({ - values: window.config.mentionValues, + values: window.config.mentionValues ?? [], requireLeadingSpace: true, menuItemTemplate: (item) => { return ` diff --git a/web_src/js/utils/match.js b/web_src/js/utils/match.js index 029fec8840..17fdfed113 100644 --- a/web_src/js/utils/match.js +++ b/web_src/js/utils/match.js @@ -32,7 +32,7 @@ export function matchMention(queryText) { // results is a map of weights, lower is better const results = new Map(); - for (const obj of window.config.mentionValues) { + for (const obj of window.config.mentionValues ?? []) { const index = obj.key.toLowerCase().indexOf(query); if (index === -1) continue; const existing = results.get(obj); |