Avoiding accessing undefined mentionValues (#26461)

The `window.config.mentionValues` might be undefined: 

```
{{if or .Participants .Assignees .MentionableTeams}}
    mentionValues: ...
{{end}}
```
pull/26448/head^2
wxiaoguang 1 year ago committed by GitHub
parent 2fc0eb913c
commit 74930b1ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      web_src/js/features/tribute.js
  2. 2
      web_src/js/utils/match.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 `

@ -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);

Loading…
Cancel
Save