From bc6aeef8241a5d7e2ace44a7ddaa82230b1b83db Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 1 May 2020 10:58:00 +0100 Subject: [PATCH] Guard against race when waiting for cross-signing to be ready Check to see if cross-signing is already set up after a verification is done to make sure it doesn't race and we end up waiting forever. --- src/stores/SetupEncryptionStore.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stores/SetupEncryptionStore.js b/src/stores/SetupEncryptionStore.js index 031c28ddb1..ae1f998b02 100644 --- a/src/stores/SetupEncryptionStore.js +++ b/src/stores/SetupEncryptionStore.js @@ -126,7 +126,7 @@ export class SetupEncryptionStore extends EventEmitter { this.emit("update"); } - onVerificationRequestChange = () => { + onVerificationRequestChange = async () => { if (this.verificationRequest.cancelled) { this.verificationRequest.off("change", this.onVerificationRequestChange); this.verificationRequest = null; @@ -136,8 +136,9 @@ export class SetupEncryptionStore extends EventEmitter { this.verificationRequest = null; // At this point, the verification has finished, we just need to wait for // cross signing to be ready to use, so wait for the user trust status to - // change. - this.phase = PHASE_BUSY; + // change (or change to DONE if it's already ready). + const crossSigningReady = await MatrixClientPeg.get().isCrossSigningReady(); + this.phase = crossSigningReady ? PHASE_DONE : PHASE_BUSY; this.emit("update"); } }