diff --git a/src/stores/SetupEncryptionStore.js b/src/stores/SetupEncryptionStore.js index cc64e24a03..742b16ec98 100644 --- a/src/stores/SetupEncryptionStore.js +++ b/src/stores/SetupEncryptionStore.js @@ -49,6 +49,12 @@ export class SetupEncryptionStore extends EventEmitter { MatrixClientPeg.get().on("crypto.verification.request", this.onVerificationRequest); MatrixClientPeg.get().on('userTrustStatusChanged', this._onUserTrustStatusChanged); + const cli = MatrixClientPeg.get(); + const requestsInProgress = cli.getVerificationRequestsToDeviceInProgress(cli.getUserId()); + if (requestsInProgress.length) { + this._setActiveVerificationRequest(requestsInProgress[0]); + } + this.fetchKeyInfo(); } @@ -168,16 +174,8 @@ export class SetupEncryptionStore extends EventEmitter { } } - onVerificationRequest = async (request) => { - if (request.otherUserId !== MatrixClientPeg.get().getUserId()) return; - - if (this.verificationRequest) { - this.verificationRequest.off("change", this.onVerificationRequestChange); - } - this.verificationRequest = request; - await request.accept(); - request.on("change", this.onVerificationRequestChange); - this.emit("update"); + onVerificationRequest = (request) => { + this._setActiveVerificationRequest(request); } onVerificationRequestChange = async () => { @@ -218,4 +216,16 @@ export class SetupEncryptionStore extends EventEmitter { // async - ask other clients for keys, if necessary MatrixClientPeg.get()._crypto.cancelAndResendAllOutgoingKeyRequests(); } + + async _setActiveVerificationRequest(request) { + if (request.otherUserId !== MatrixClientPeg.get().getUserId()) return; + + if (this.verificationRequest) { + this.verificationRequest.off("change", this.onVerificationRequestChange); + } + this.verificationRequest = request; + await request.accept(); + request.on("change", this.onVerificationRequestChange); + this.emit("update"); + } }