aboutsummaryrefslogtreecommitdiff
path: root/ext/js/background
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/background')
-rw-r--r--ext/js/background/backend.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index cdbfde1e..07d6fd98 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -512,8 +512,22 @@ class Backend {
);
}
- async _onApiNoteView({noteId}) {
- return await this._anki.guiBrowseNote(noteId);
+ async _onApiNoteView({noteId, mode, allowFallback}) {
+ if (mode === 'edit') {
+ try {
+ await this._anki.guiEditNote(noteId);
+ return 'edit';
+ } catch (e) {
+ if (!this._anki.isErrorUnsupportedAction(e)) {
+ throw e;
+ } else if (!allowFallback) {
+ throw new Error('Mode not supported');
+ }
+ }
+ }
+ // Fallback
+ await this._anki.guiBrowseNote(noteId);
+ return 'browse';
}
async _onApiSuspendAnkiCardsForNote({noteId}) {