Fix overlapping version checks (#716)
This commit is contained in:
parent
d856e4caac
commit
b3eb2cb1ef
@ -21,6 +21,7 @@ class AnkiConnect {
|
|||||||
this._server = server;
|
this._server = server;
|
||||||
this._localVersion = 2;
|
this._localVersion = 2;
|
||||||
this._remoteVersion = 0;
|
this._remoteVersion = 0;
|
||||||
|
this._versionCheckPromise = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setServer(server) {
|
setServer(server) {
|
||||||
@ -98,7 +99,12 @@ class AnkiConnect {
|
|||||||
|
|
||||||
async _checkVersion() {
|
async _checkVersion() {
|
||||||
if (this._remoteVersion < this._localVersion) {
|
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) {
|
if (this._remoteVersion < this._localVersion) {
|
||||||
throw new Error('Extension and plugin versions incompatible');
|
throw new Error('Extension and plugin versions incompatible');
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user