merged mode: remove options.dictionary.main

This commit is contained in:
siikamiika 2017-10-12 01:10:05 +03:00
parent 7783aa4c1a
commit 4e57fa1ad1
3 changed files with 3 additions and 10 deletions

View File

@ -154,10 +154,6 @@ function optionsSetDefaults(options) {
dictionaries: {},
dictionary: {
main: ''
},
anki: {
enable: false,
server: 'http://127.0.0.1:8765',

View File

@ -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);

View File

@ -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);