This commit is contained in:
Alex Yatskov 2017-07-10 15:20:07 -07:00
parent 28bc1449d1
commit a73b8fbab7
2 changed files with 6 additions and 8 deletions

View File

@ -87,14 +87,12 @@ class Translator {
return {length, definitions}; return {length, definitions};
} }
async findTermsDeinflected(text, dictionaries, cache) { async findTermsDeinflected(text, titles, cache) {
await this.prepare();
const definer = async term => { const definer = async term => {
if (cache.hasOwnProperty(term)) { if (cache.hasOwnProperty(term)) {
return cache[term]; return cache[term];
} else { } else {
return cache[term] = await this.database.findTerms(term, dictionaries); return cache[term] = await this.database.findTerms(term, titles);
} }
}; };
@ -108,8 +106,6 @@ class Translator {
} }
async findKanji(text, dictionaries) { async findKanji(text, dictionaries) {
await this.prepare();
let definitions = []; let definitions = [];
const processed = {}; const processed = {};
const titles = Object.keys(dictionaries); const titles = Object.keys(dictionaries);
@ -129,7 +125,6 @@ class Translator {
return definitions; return definitions;
} }
static loadRules(url) { static loadRules(url) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();

View File

@ -25,9 +25,12 @@ window.yomichan = new class {
this.anki = new AnkiNull(); this.anki = new AnkiNull();
this.options = null; this.options = null;
this.translator.prepare().then(optionsLoad).then(this.optionsSet.bind(this)).then(() => { this.translator.prepare().then(optionsLoad).then(options => {
this.optionsSet(options);
chrome.commands.onCommand.addListener(this.onCommand.bind(this)); chrome.commands.onCommand.addListener(this.onCommand.bind(this));
chrome.runtime.onMessage.addListener(this.onMessage.bind(this)); chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
if (this.options.general.showGuide) { if (this.options.general.showGuide) {
chrome.tabs.create({url: chrome.extension.getURL('/bg/guide.html')}); chrome.tabs.create({url: chrome.extension.getURL('/bg/guide.html')});
} }