From 8f3eb89f8b0fc7568b4f5c087818fe2beac52748 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 23 Jun 2017 10:48:21 +0100 Subject: [PATCH] Fix potential race in setting client listeners --- src/components/structures/MatrixChat.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/structures/MatrixChat.js b/src/components/structures/MatrixChat.js index 0992d486f6..b618caa1c9 100644 --- a/src/components/structures/MatrixChat.js +++ b/src/components/structures/MatrixChat.js @@ -548,7 +548,12 @@ module.exports = React.createClass({ this._onLoggedOut(); break; case 'will_start_client': - this._onWillStartClient(); + this.setState({ready: false}, () => { + // if the client is about to start, we are, by definition, not ready. + // Set ready to false now, then it'll be set to true when the sync + // listener we set below fires. + this._onWillStartClient(); + }); break; case 'new_version': this.onVersion( @@ -1012,10 +1017,6 @@ module.exports = React.createClass({ */ _onWillStartClient() { const self = this; - // if the client is about to start, we are, by definition, not ready. - // Set ready to false now, then it'll be set to true when the sync - // listener we set below fires. - this.setState({ready: false}); // reset the 'have completed first sync' flag, // since we're about to start the client and therefore about