Merge pull request #590 from matrix-org/luke/fix-membereventlistsummary-performance

Improve the performance of MemberEventListSummary
This commit is contained in:
Richard van der Hoff 2016-12-16 10:53:51 +00:00 committed by GitHub
commit b8c0fa507e
2 changed files with 99 additions and 71 deletions

View file

@ -298,6 +298,15 @@ module.exports = React.createClass({
// Wrap consecutive member events in a ListSummary
if (isMembershipChange(mxEv)) {
let ts1 = mxEv.getTs();
// Ensure that the key of the MemberEventListSummary does not change with new
// member events. This will prevent it from being re-created unnecessarily, and
// instead will allow new props to be provided. In turn, the shouldComponentUpdate
// method on MELS can be used to prevent unnecessary renderings.
//
// Whilst back-paginating with a MELS at the top of the panel, prevEvent will be null,
// so use the key "membereventlistsummary-initial". Otherwise, use the ID of the first
// membership event, which will not change during forward pagination.
const key = "membereventlistsummary-" + (prevEvent ? mxEv.getId() : "initial");
if (this._wantsDateSeparator(prevEvent, ts1)) {
let dateSeparator = <li key={ts1+'~'}><DateSeparator key={ts1+'~'} ts={ts1}/></li>;
@ -334,7 +343,7 @@ module.exports = React.createClass({
ret.push(
<MemberEventListSummary
key={mxEv.getId()}
key={key}
events={summarisedEvents}
data-scroll-token={eventId}>
{eventTiles}