From 1dcfbf6ba6516d05f756d26bf84049d94776ab14 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 14 Jan 2021 22:42:11 -0500 Subject: 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 --- ext/mixed/js/api.js | 4 ++++ ext/mixed/js/display.js | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'ext/mixed') diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index 4fde30b0..433a52e2 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -93,6 +93,10 @@ const api = (() => { return this._invoke('noteView', {noteId}); } + suspendAnkiCardsForNote(noteId) { + return this._invoke('suspendAnkiCardsForNote', {noteId}); + } + getDefinitionAudioInfo(source, expression, reading, details) { return this._invoke('getDefinitionAudioInfo', {source, expression, reading, details}); } 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 { -- cgit v1.2.3