summaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-09-09 21:07:18 -0400
committerGitHub <noreply@github.com>2020-09-09 21:07:18 -0400
commit58e5ddfde00eb28ac3a12cd2c83c1088a63d7d23 (patch)
tree7ea4b3c26cec99e22a73b6edcbd17e101a2e4b29 /ext/bg/js/backend.js
parent5d2261acb972374c45fca022f121609405873e90 (diff)
Generalize AnkiNoteBuilder to not use audioSystem directly (#796)
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 5fdca569..1bc831e9 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -58,8 +58,8 @@ class Backend {
useCache: false
});
this._ankiNoteBuilder = new AnkiNoteBuilder({
- audioSystem: this._audioSystem,
renderTemplate: this._renderTemplate.bind(this),
+ getDefinitionAudio: this._getDefinitionAudio.bind(this),
getClipboardImage: this._onApiClipboardImageGet.bind(this),
getScreenshot: this._getScreenshot.bind(this)
});
@@ -124,7 +124,8 @@ class Backend {
['getSettings', {async: false, contentScript: true, handler: this._onApiGetSettings.bind(this)}],
['setAllSettings', {async: true, contentScript: false, handler: this._onApiSetAllSettings.bind(this)}],
['getOrCreateSearchPopup', {async: true, contentScript: true, handler: this._onApiGetOrCreateSearchPopup.bind(this)}],
- ['isTabSearchPopup', {async: true, contentScript: true, handler: this._onApiIsTabSearchPopup.bind(this)}]
+ ['isTabSearchPopup', {async: true, contentScript: true, handler: this._onApiIsTabSearchPopup.bind(this)}],
+ ['getDefinitionAudio', {async: true, contentScript: true, handler: this._onApiGetDefinitionAudio.bind(this)}]
]);
this._messageHandlersWithProgress = new Map([
['deleteDictionary', {async: true, contentScript: false, handler: this._onApiDeleteDictionary.bind(this)}]
@@ -827,6 +828,10 @@ class Backend {
return (tab !== null);
}
+ async _onApiGetDefinitionAudio({definition, sources, details}) {
+ return this._getDefinitionAudio(definition, sources, details);
+ }
+
// Command handlers
async _onCommandSearch(params) {
@@ -1631,4 +1636,8 @@ class Backend {
}
}
}
+
+ async _getDefinitionAudio(definition, sources, details) {
+ return await this._audioSystem.getDefinitionAudio(definition, sources, details);
+ }
}