From 8b25223026d6406929f4d6ab7d6b6ab091b1007a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 15 Apr 2020 13:45:12 +0100 Subject: [PATCH] fix onLoggedIn getting called twice Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MatrixChat.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 61b72f650b..519b39d436 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -1902,13 +1902,19 @@ export default createReactClass({ const cli = MatrixClientPeg.get(); // We're checking `isCryptoAvailable` here instead of `isCryptoEnabled` // because the client hasn't been started yet. - if (!isCryptoAvailable()) { + const cryptoAvailable = isCryptoAvailable(); + if (!cryptoAvailable) { this._onLoggedIn(); } this.setState({ pendingInitialSync: true }); await this.firstSyncPromise.promise; + if (!cryptoAvailable) { + this.setState({ pendingInitialSync: false }); + return setLoggedInPromise; + } + // Test for the master cross-signing key in SSSS as a quick proxy for // whether cross-signing has been set up on the account. const masterKeyInStorage = !!cli.getAccountData("m.cross_signing.master");