Don't update state when no change to read marker
It turns out to be quite expensive to update the state, because we can't do shouldComponentUpdate on any of the sub-components (because RRs and local echo sneak in through the back door), and we don't want to trigger a whole render cycle every time someone presses a key.
This commit is contained in:
parent
9db58de119
commit
1e095e105a
1 changed files with 11 additions and 3 deletions
|
@ -321,9 +321,11 @@ var TimelinePanel = React.createClass({
|
||||||
|
|
||||||
// the read-marker should become invisible, so that if the user scrolls
|
// the read-marker should become invisible, so that if the user scrolls
|
||||||
// down, they don't see it.
|
// down, they don't see it.
|
||||||
|
if(this.state.readMarkerVisible) {
|
||||||
this.setState({
|
this.setState({
|
||||||
readMarkerVisible: false,
|
readMarkerVisible: false,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/* jump down to the bottom of this room, where new events are arriving
|
/* jump down to the bottom of this room, where new events are arriving
|
||||||
|
@ -556,6 +558,12 @@ var TimelinePanel = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_setReadMarker: function(eventId, eventTs) {
|
_setReadMarker: function(eventId, eventTs) {
|
||||||
|
if (TimelinePanel.roomReadMarkerMap[this.props.room.roomId] == eventId) {
|
||||||
|
// don't update the state (and cause a re-render) if there is
|
||||||
|
// no change to the RM.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ideally we'd sync these via the server, but for now just stash them
|
// ideally we'd sync these via the server, but for now just stash them
|
||||||
// in a map.
|
// in a map.
|
||||||
TimelinePanel.roomReadMarkerMap[this.props.room.roomId] = eventId;
|
TimelinePanel.roomReadMarkerMap[this.props.room.roomId] = eventId;
|
||||||
|
|
Loading…
Reference in a new issue