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.
This commit is contained in:
parent
db834b315a
commit
4eb9fa6922
1 changed files with 7 additions and 0 deletions
|
@ -144,6 +144,7 @@ module.exports = React.createClass({
|
||||||
// the end of the live timeline. It has the effect of hiding the
|
// the end of the live timeline. It has the effect of hiding the
|
||||||
// 'scroll to bottom' knob, among a couple of other things.
|
// 'scroll to bottom' knob, among a couple of other things.
|
||||||
atEndOfLiveTimeline: true,
|
atEndOfLiveTimeline: true,
|
||||||
|
atEndOfLiveTimelineInit: false, // used by componentDidUpdate to avoid unnecessary checks
|
||||||
|
|
||||||
showTopUnreadMessagesBar: false,
|
showTopUnreadMessagesBar: false,
|
||||||
|
|
||||||
|
@ -428,6 +429,12 @@ module.exports = React.createClass({
|
||||||
roomView.addEventListener('dragend', this.onDragLeaveOrEnd);
|
roomView.addEventListener('dragend', this.onDragLeaveOrEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.refs.messagePanel && !this.state.atEndOfLiveTimelineInit) {
|
||||||
|
this.setState({
|
||||||
|
atEndOfLiveTimelineInit: true,
|
||||||
|
atEndOfLiveTimeline: this.refs.messagePanel.isAtEndOfLiveTimeline(),
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount: function() {
|
componentWillUnmount: function() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue