aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-05 22:50:10 -0400
committerGitHub <noreply@github.com>2020-10-05 22:50:10 -0400
commit7ce87c51b4fcb5d0507b4668b210ffe2531fea22 (patch)
treea34749e1a0e8c6ec441ec113405ecb144b5f0b71 /ext/bg/js
parent0cfaa1a5a8dbe7c1c14ac17e40be1d547c1cd8a1 (diff)
Don't add duplicate definitions (#889)
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/translator.js8
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);