summaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-14 16:59:44 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-29 12:33:03 -0500
commit3033fea31e4bc9ba7198d2d31d6f6046813926d1 (patch)
tree4d6e212260ee9bca9f4807fe6d6fefbe9ed12f22 /ext/bg/js/backend.js
parent024f969bfd884e43cd40f408d0e3ba32839be45f (diff)
Treat null templates as the default value
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index ca03f94d..1a874dc8 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -321,6 +321,7 @@ class Backend {
async _onApiDefinitionAdd({definition, mode, context, optionsContext}) {
const options = await this.getOptions(optionsContext);
+ const templates = Backend._getTemplates(options);
if (mode !== 'kanji') {
await audioInject(
@@ -339,19 +340,20 @@ class Backend {
);
}
- const note = await dictNoteFormat(definition, mode, options);
+ const note = await dictNoteFormat(definition, mode, options, templates);
return this.anki.addNote(note);
}
async _onApiDefinitionsAddable({definitions, modes, optionsContext}) {
const options = await this.getOptions(optionsContext);
+ const templates = Backend._getTemplates(options);
const states = [];
try {
const notes = [];
for (const definition of definitions) {
for (const mode of modes) {
- const note = await dictNoteFormat(definition, mode, options);
+ const note = await dictNoteFormat(definition, mode, options, templates);
notes.push(note);
}
}
@@ -672,6 +674,11 @@ class Backend {
return 'chrome';
}
}
+
+ static _getTemplates(options) {
+ const templates = options.anki.fieldTemplates;
+ return typeof templates === 'string' ? templates : profileOptionsGetDefaultFieldTemplates();
+ }
}
Backend._messageHandlers = new Map([