From 0ec5eebfc9e8e2116f77fa926b8dd9bfe31b9197 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 10 Nov 2016 13:03:17 +0000 Subject: [PATCH] Hoist isMembershipChange out of for loop --- src/components/structures/MessagePanel.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index cf25ff88a2..5e79232e75 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -276,6 +276,11 @@ module.exports = React.createClass({ this.currentGhostEventId = null; } + var isMembershipChange = (e) => + e.getType() === 'm.room.member' + && ['join', 'leave'].indexOf(e.event.content.membership) !== -1 + && (!e.event.prev_content || e.event.content.membership !== e.event.prev_content.membership); + for (i = 0; i < this.props.events.length; i++) { var mxEv = this.props.events[i]; var wantTile = true; @@ -287,11 +292,6 @@ module.exports = React.createClass({ var last = (i == lastShownEventIndex); - var isMembershipChange = (e) => - e.getType() === 'm.room.member' - && ['join', 'leave'].indexOf(e.event.content.membership) !== -1 - && (!e.event.prev_content || e.event.content.membership !== e.event.prev_content.membership); - // Wrap consecutive member events in a ListSummary if (isMembershipChange(mxEv)) { let summarisedEvents = [mxEv];