diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-10-05 22:50:10 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-05 22:50:10 -0400 |
commit | 7ce87c51b4fcb5d0507b4668b210ffe2531fea22 (patch) | |
tree | a34749e1a0e8c6ec441ec113405ecb144b5f0b71 /ext | |
parent | 0cfaa1a5a8dbe7c1c14ac17e40be1d547c1cd8a1 (diff) |
Don't add duplicate definitions (#889)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bg/js/translator.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 1b2bd738..e11d0269 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -597,7 +597,7 @@ class Translator { _mergeByGlossary(definitions, glossaryDefinitionGroupMap) { for (const definition of definitions) { - const {expression, reading, dictionary, glossary} = definition; + const {expression, reading, dictionary, glossary, id} = definition; const key = this._createMapKey([dictionary, ...glossary]); let group = glossaryDefinitionGroupMap.get(key); @@ -605,11 +605,15 @@ class Translator { group = { expressions: new Set(), readings: new Set(), - definitions: [] + definitions: [], + definitionIds: new Set() }; glossaryDefinitionGroupMap.set(key, group); } + const {definitionIds} = group; + if (definitionIds.has(id)) { continue; } + definitionIds.add(id); group.expressions.add(expression); group.readings.add(reading); group.definitions.push(definition); |