From 4eb9fa6922e949bb01a29e6c0e2064be19e4e114 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 26 Mar 2019 14:22:48 -0600 Subject: [PATCH] Check if the message panel is at the end of the timeline on init Fixes https://github.com/vector-im/riot-web/issues/8503 componentDidUpdate is called a lot, and we don't really want to keep checking the messagePanel, so this introduces a new flag to check if the init is even needed. --- src/components/structures/RoomView.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 34c711ee6f..23d5b2f127 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -144,6 +144,7 @@ module.exports = React.createClass({ // the end of the live timeline. It has the effect of hiding the // 'scroll to bottom' knob, among a couple of other things. atEndOfLiveTimeline: true, + atEndOfLiveTimelineInit: false, // used by componentDidUpdate to avoid unnecessary checks showTopUnreadMessagesBar: false, @@ -428,6 +429,12 @@ module.exports = React.createClass({ roomView.addEventListener('dragend', this.onDragLeaveOrEnd); } } + if (this.refs.messagePanel && !this.state.atEndOfLiveTimelineInit) { + this.setState({ + atEndOfLiveTimelineInit: true, + atEndOfLiveTimeline: this.refs.messagePanel.isAtEndOfLiveTimeline(), + }); + } }, componentWillUnmount: function() {