From 2d6ba056d15074b9be4a3522fa17d996b3ade537 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 14 Jun 2017 16:48:34 +0100 Subject: [PATCH 1/4] Attempt to follow closely what RoomView did pre-ILAG In terms of peeking and what happens to the state when joining. This is another attempt to mitigate https://github.com/vector-im/riot-web/issues/4307 --- src/components/structures/RoomView.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 79420e776a..4af17f7a1a 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -170,6 +170,12 @@ module.exports = React.createClass({ isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(), }; + // NB: This does assume that the roomID will not change for the lifetime of + // the RoomView instance + if (initial) { + newState.room = MatrixClientPeg.get().getRoom(newState.roomId); + } + // Clear the search results when clicking a search result (which changes the // currently scrolled to event, this.state.initialEventId). if (this.state.initialEventId !== newState.initialEventId) { @@ -186,7 +192,6 @@ module.exports = React.createClass({ // At this point, this.state.roomId could be null (e.g. the alias might not // have been resolved yet) so anything called here must handle this case. this._onHaveRoom(); - this.onRoom(MatrixClientPeg.get().getRoom(this.state.roomId)); }); }, @@ -205,7 +210,7 @@ module.exports = React.createClass({ // NB. We peek if we are not in the room, although if we try to peek into // a room in which we have a member event (ie. we've left) synapse will just // send us the same data as we get in the sync (ie. the last events we saw). - const room = MatrixClientPeg.get().getRoom(this.state.roomId); + const room = this.state.room; let isUserJoined = null; if (room) { isUserJoined = room.hasMembershipState( @@ -220,7 +225,6 @@ module.exports = React.createClass({ this.onJoinButtonClicked(); } else if (this.state.roomId) { console.log("Attempting to peek into room %s", this.state.roomId); - this.setState({ peekLoading: true, }); @@ -602,7 +606,7 @@ module.exports = React.createClass({ }, onRoom: function(room) { - if (!room || room.roomId !== this.state.roomId) { + if (!room || room.roomId !== this.state.roomId || !this.state.joining) { return; } this.setState({ From b5fd78a97f2c2cda60bb5632802855f67b3eb996 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 14 Jun 2017 16:50:46 +0100 Subject: [PATCH 2/4] Only attempt to peek once in the lifetime of RoomView --- src/components/structures/RoomView.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 4af17f7a1a..186aaf6f75 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -191,7 +191,9 @@ module.exports = React.createClass({ this.setState(newState, () => { // At this point, this.state.roomId could be null (e.g. the alias might not // have been resolved yet) so anything called here must handle this case. - this._onHaveRoom(); + if (initial) { + this._onHaveRoom(); + } }); }, From ed5f01d46f24e1a53d38a849910d14900d53314a Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 14 Jun 2017 16:53:21 +0100 Subject: [PATCH 3/4] Add logging for diagnosis --- src/components/structures/RoomView.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 186aaf6f75..7313b2bc33 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -170,6 +170,15 @@ module.exports = React.createClass({ isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(), }; + // Temporary logging to diagnose https://github.com/vector-im/riot-web/issues/4307 + console.log( + 'RVS update:', + newState.roomId, + newState.roomAlias, + 'loading?', newState.roomLoading, + 'joining?', newState.joining, + ); + // NB: This does assume that the roomID will not change for the lifetime of // the RoomView instance if (initial) { From 58554cce5376a39578667706d20db62cdef2669a Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 14 Jun 2017 17:13:13 +0100 Subject: [PATCH 4/4] Remove racey condition joining might become false before we get the room down the sync --- src/components/structures/RoomView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 7313b2bc33..0cd8a95938 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -617,7 +617,7 @@ module.exports = React.createClass({ }, onRoom: function(room) { - if (!room || room.roomId !== this.state.roomId || !this.state.joining) { + if (!room || room.roomId !== this.state.roomId) { return; } this.setState({