Skip to content

Commit

Permalink
Fix potential undefined hit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed Feb 8, 2025
1 parent 4e31dbd commit c6eb0bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ext/js/data/anki-template-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ export function getDynamicTemplates(options, dictionaryInfo) {
for (const dictionary of options.dictionaries) {
const currentDictionaryInfo = dictionaryInfo.find(({title}) => title === dictionary.name);
if (!dictionary.enabled) { continue; }
if (currentDictionaryInfo?.counts?.terms.total === 0) { continue; }
const totalTerms = currentDictionaryInfo?.counts?.terms?.total;
if (!!totalTerms && totalTerms > 0) { continue; }
dynamicTemplates += `
{{#*inline "single-glossary-${getKebabCase(dictionary.name)}"}}
{{~> glossary selectedDictionary='${escapeDictName(dictionary.name)}'}}
Expand Down Expand Up @@ -138,7 +139,8 @@ export function getDynamicFieldMarkers(dictionaries, dictionaryInfo) {
for (const dictionary of dictionaries) {
const currentDictionaryInfo = dictionaryInfo.find(({title}) => title === dictionary.name);
if (!dictionary.enabled) { continue; }
if (currentDictionaryInfo?.counts?.terms.total === 0) { continue; }
const totalTerms = currentDictionaryInfo?.counts?.terms?.total;
if (!!totalTerms && totalTerms > 0) { continue; }
markers.push(`single-glossary-${getKebabCase(dictionary.name)}`);
}
return markers;
Expand Down

0 comments on commit c6eb0bc

Please sign in to comment.