summaryrefslogtreecommitdiff
path: root/ext/bg/js/anki.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-11-08 15:53:06 -0500
committerGitHub <noreply@github.com>2020-11-08 15:53:06 -0500
commit4e3040941038acc4f739e4077aee14cb64d3aa81 (patch)
treea9c4e19afeba313d5b9b942b4e75f7d06e44475e /ext/bg/js/anki.js
parent0cbc6523e67ccae01d1a4d7547ef38017594c149 (diff)
Add api.isAnkiConnected (#1011)
Diffstat (limited to 'ext/bg/js/anki.js')
-rw-r--r--ext/bg/js/anki.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js
index 84d81d49..8395518f 100644
--- a/ext/bg/js/anki.js
+++ b/ext/bg/js/anki.js
@@ -40,6 +40,15 @@ class AnkiConnect {
this._enabled = value;
}
+ async isConnected() {
+ try {
+ await this._invoke('version');
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+
async addNote(note) {
if (!this._enabled) { return null; }
await this._checkVersion();