Merge pull request #1142 from matrix-org/dbkr/fix_potential_start_client_race_2

Fix potential race in setting client listeners
pull/21833/head
Luke Barnard 2017-06-23 12:56:14 +01:00 committed by GitHub
commit cddac3516b
1 changed files with 6 additions and 5 deletions

View File

@ -548,7 +548,12 @@ module.exports = React.createClass({
this._onLoggedOut();
break;
case 'will_start_client':
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