summaryrefslogtreecommitdiff
path: root/ext/mixed/js/display.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-14 22:42:11 -0500
committerGitHub <noreply@github.com>2021-01-14 22:42:11 -0500
commit1dcfbf6ba6516d05f756d26bf84049d94776ab14 (patch)
tree538a1a4346a4f98ba366949eda33b4e981e58766 /ext/mixed/js/display.js
parentd9f5d21d15a8239ecf349d254606be2c8fa70d31 (diff)
Support suspending new anki cards (#1240)
* Add new option: anki.suspendNewCards * Update Anki APIs * Suspend card based on options * Add setting * Disable wrap for toggle property
Diffstat (limited to 'ext/mixed/js/display.js')
-rw-r--r--ext/mixed/js/display.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 45019039..67498d01 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -1181,10 +1181,18 @@ class Display extends EventDispatcher {
const overrideToken = this._progressIndicatorVisible.setOverride(true);
try {
+ const {anki: {suspendNewCards}} = this._options;
const noteContext = this._getNoteContext();
const note = await this._createNote(definition, mode, noteContext, true);
const noteId = await api.addAnkiNote(note);
if (noteId) {
+ if (suspendNewCards) {
+ try {
+ await api.suspendAnkiCardsForNote(noteId);
+ } catch (e) {
+ // NOP
+ }
+ }
button.disabled = true;
this._viewerButtonShow(definitionIndex, noteId);
} else {