diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-18 14:14:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-18 14:14:52 -0400 |
commit | 5b3d7fadc3534ba27eee971dac4ba5ee475c4e3d (patch) | |
tree | 5af68163c940fc272563e6759e3996206a33e32a /ext/bg/js/backend.js | |
parent | 9297eb45aef3bad50fe9cf5e453aa97288609601 (diff) | |
parent | 06e95b8747e7222d3aa513cda28b0878a11921d9 (diff) |
Merge pull request #453 from toasted-nutbread/reuse-anki-instance
Reuse AnkiConnect instance
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r-- | ext/bg/js/backend.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 04a3b932..a1b788df 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -18,7 +18,6 @@ /* global * AnkiConnect * AnkiNoteBuilder - * AnkiNull * AudioSystem * AudioUriBuilder * BackendApiForwarder @@ -46,7 +45,7 @@ class Backend { this.database = new Database(); this.dictionaryImporter = new DictionaryImporter(); this.translator = new Translator(this.database); - this.anki = new AnkiNull(); + this.anki = new AnkiConnect(); this.mecab = new Mecab(); this.clipboardMonitor = new ClipboardMonitor({getClipboard: this._onApiClipboardGet.bind(this)}); this.options = null; @@ -55,6 +54,7 @@ class Backend { this.audioSystem = new AudioSystem({getAudioUri: this._getAudioUri.bind(this)}); this.audioUriBuilder = new AudioUriBuilder(); this.ankiNoteBuilder = new AnkiNoteBuilder({ + anki: this.anki, audioSystem: this.audioSystem, renderTemplate: this._renderTemplate.bind(this) }); @@ -214,7 +214,8 @@ class Backend { this.setExtensionBadgeText(''); } - this.anki = options.anki.enable ? new AnkiConnect(options.anki.server) : new AnkiNull(); + this.anki.setServer(options.anki.server); + this.anki.setEnabled(options.anki.enable); if (options.parsing.enableMecabParser) { this.mecab.startListener(); @@ -505,8 +506,7 @@ class Backend { await this.ankiNoteBuilder.injectScreenshot( definition, options.anki.terms.fields, - details.screenshot, - this.anki + details.screenshot ); } |