Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-28 04:36:11 +01:00

Avoiding accessing undefined tributeValues #26461 (#26462)

Backport #26461
This commit is contained in:
wxiaoguang 2023-08-12 16:30:29 +08:00 committed by GitHub
parent 2bdc38e592
commit 9112ce22a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -31,7 +31,7 @@ function makeCollections({mentions, emoji}) {
if (mentions) { if (mentions) {
collections.push({ collections.push({
values: window.config.tributeValues, values: window.config.tributeValues ?? [],
requireLeadingSpace: true, requireLeadingSpace: true,
menuItemTemplate: (item) => { menuItemTemplate: (item) => {
return ` return `

View file

@ -32,7 +32,7 @@ export function matchMention(queryText) {
// results is a map of weights, lower is better // results is a map of weights, lower is better
const results = new Map(); const results = new Map();
for (const obj of window.config.tributeValues) { for (const obj of window.config.tributeValues ?? []) {
const index = obj.key.toLowerCase().indexOf(query); const index = obj.key.toLowerCase().indexOf(query);
if (index === -1) continue; if (index === -1) continue;
const existing = results.get(obj); const existing = results.get(obj);