aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/bg/js/options.js4
-rw-r--r--ext/bg/js/settings.js4
-rw-r--r--ext/bg/js/translator.js5
3 files changed, 3 insertions, 10 deletions
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 0aa6d7c6..b49c32da 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -154,10 +154,6 @@ function optionsSetDefaults(options) {
dictionaries: {},
- dictionary: {
- main: ''
- },
-
anki: {
enable: false,
server: 'http://127.0.0.1:8765',
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index cab9c056..6016b38a 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -61,9 +61,6 @@ async function formRead() {
const priority = parseInt(dictionary.find('.dict-priority').val(), 10);
const enabled = dictionary.find('.dict-enabled').prop('checked');
const main = dictionary.find('.dict-main').prop('checked');
- if (main) {
- optionsNew.dictionary.main = title;
- }
optionsNew.dictionaries[title] = {priority, enabled, main};
});
@@ -302,7 +299,6 @@ async function onDictionaryPurge(e) {
await utilDatabasePurge();
const options = await optionsLoad();
options.dictionaries = {};
- options.dictionary.main = '';
await optionsSave(options);
await dictionaryGroupsPopulate(options);
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index 737abd08..99344b95 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -50,10 +50,11 @@ class Translator {
async findTermsMerged(text, dictionaries, alphanumeric) {
const options = await apiOptionsGet();
+ const mainDictionary = Object.keys(options.dictionaries).filter(dict => options.dictionaries[dict].main).concat([''])[0];
const titles = Object.keys(dictionaries);
const {length, definitions} = await this.findTerms(text, dictionaries, alphanumeric);
- const definitionsBySequence = dictTermsMergeBySequence(definitions, options.dictionary.main);
+ const definitionsBySequence = dictTermsMergeBySequence(definitions, mainDictionary);
const definitionsMerged = [];
const mergedByTermIndices = new Set();
@@ -64,7 +65,7 @@ class Translator {
const result = definitionsBySequence[sequence];
- const rawDefinitionsBySequence = await this.database.findTermsBySequence(Number(sequence), options.dictionary.main);
+ const rawDefinitionsBySequence = await this.database.findTermsBySequence(Number(sequence), mainDictionary);
const definitionsByGloss = dictTermsMergeByGloss(result, rawDefinitionsBySequence);
dictTermsMergeByGloss(result, definitionsBySequence['-1'], definitionsByGloss, mergedByTermIndices);