From 531fc3ac54363c5a1efebc5d850613f8639f277b Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 11 Sep 2017 17:57:52 +0100 Subject: [PATCH 1/2] Fix 'Failed to load timeline position' regression Ignore the update that comes in from the RoomViewStore when the current room changes or we save our scoll state against the new room rather than the old one. Fixes https://github.com/vector-im/riot-web/issues/5010 --- src/components/structures/RoomView.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 8a0eeb50b9..6cb8dc3e7b 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -157,6 +157,19 @@ module.exports = React.createClass({ if (this.unmounted) { return; } + + if (!initial && this.state.roomId !== RoomViewStore.getRoomId()) { + // RoomView explicitly does not support changing what room + // is being viewed: instead it should just be re-mounted when + // switching rooms. Therefore, if the room ID changes, we + // ignore this. We either need to do this or add code to handle + // saving the scroll position (otherwise we end up saving the + // scroll position against the wrong room). Given that doing the + // setState here would cause a bunch of unnecessary work, we + // just ignore the change. + return; + } + const newState = { roomId: RoomViewStore.getRoomId(), roomAlias: RoomViewStore.getRoomAlias(), From 6cb98d719631fd18ef571895008f2771895dc7fb Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 11 Sep 2017 18:39:30 +0100 Subject: [PATCH 2/2] Hopefully make comment clearer --- src/components/structures/RoomView.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 6cb8dc3e7b..2a6cf0aee4 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -164,9 +164,12 @@ module.exports = React.createClass({ // switching rooms. Therefore, if the room ID changes, we // ignore this. We either need to do this or add code to handle // saving the scroll position (otherwise we end up saving the - // scroll position against the wrong room). Given that doing the - // setState here would cause a bunch of unnecessary work, we - // just ignore the change. + // scroll position against the wrong room). + + // Given that doing the setState here would cause a bunch of + // unnecessary work, we just ignore the change since we know + // that if the current room ID has changed from what we thought + // it was, it means we're about to be unmounted. return; }