diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-10-04 13:09:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-04 13:09:04 -0400 |
commit | 7e31dcca3960a269be537196971f06112b6a6be9 (patch) | |
tree | 954c8102676561b26dcc1d9f9a1bdf0557fda966 /ext/bg/js/translator.js | |
parent | 2bd82353e46ecc8c16f2b55f81c8daae6f73e12e (diff) |
Move deinflection reasons setup to backend (#880)
* Move deinflection reasons setup to backend
* Remove async
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r-- | ext/bg/js/translator.js | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 7af3f61f..3dbae411 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -38,11 +38,11 @@ class Translator { /** * Initializes the instance for use. The public API should not be used until - * this function has been called and await'd. + * this function has been called. + * @param deinflectionReasons The raw deinflections reasons data that the Deinflector uses. */ - async prepare() { - const reasons = await this._fetchJsonAsset('/bg/lang/deinflect.json'); - this._deinflector = new Deinflector(reasons); + prepare(deinflectionReasons) { + this._deinflector = new Deinflector(deinflectionReasons); } /** @@ -747,21 +747,6 @@ class Translator { return newText; } - async _fetchJsonAsset(url) { - const response = await fetch(chrome.runtime.getURL(url), { - method: 'GET', - mode: 'no-cors', - cache: 'default', - credentials: 'omit', - redirect: 'follow', - referrerPolicy: 'no-referrer' - }); - if (!response.ok) { - throw new Error(`Failed to fetch ${url}: ${response.status}`); - } - return await response.json(); - } - _getSecondarySearchDictionaryMap(enabledDictionaryMap) { const secondarySearchDictionaryMap = new Map(); for (const [title, dictionary] of enabledDictionaryMap.entries()) { |