summaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-08-09 13:17:15 -0400
committerGitHub <noreply@github.com>2020-08-09 13:17:15 -0400
commitb3eb2cb1ef9fd28ea2dadb9eda8568a3b6958e9c (patch)
treec67fcd531523568828ccb5ab555c7b6aa6f15361 /ext/bg
parentd856e4caac0d3ddf8277ff20d92de4af8e351c16 (diff)
Fix overlapping version checks (#716)
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/anki.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/bg/js/anki.js b/ext/bg/js/anki.js
index a72dff2a..29ae5f0b 100644
--- a/ext/bg/js/anki.js
+++ b/ext/bg/js/anki.js
@@ -21,6 +21,7 @@ class AnkiConnect {
this._server = server;
this._localVersion = 2;
this._remoteVersion = 0;
+ this._versionCheckPromise = null;
}
setServer(server) {
@@ -98,7 +99,12 @@ class AnkiConnect {
async _checkVersion() {
if (this._remoteVersion < this._localVersion) {
- this._remoteVersion = await this._invoke('version');
+ if (this._versionCheckPromise === null) {
+ const promise = this._invoke('version');
+ promise.finally(() => { this._versionCheckPromise = null; });
+ this._versionCheckPromise = promise;
+ }
+ this._remoteVersion = await this._versionCheckPromise;
if (this._remoteVersion < this._localVersion) {
throw new Error('Extension and plugin versions incompatible');
}