From 3ec7940d12efa149c9be548c2adb104faa2eb6e1 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 10 Nov 2016 17:26:36 +0000 Subject: [PATCH] Inline renderEvents --- src/components/structures/MessagePanel.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index ed65314890..298372a4d8 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -308,28 +308,23 @@ module.exports = React.createClass({ // At this point, i = this.props.events.length OR i = the index of the last // MembershipChange in a sequence of MembershipChanges - let renderEvents = (pEvent, events) => { - if (events.length === 0) { - return null; + let eventTiles = summarisedEvents.map( + (e) => { + let ret = this._getTilesForEvent(prevEvent, e); + prevEvent = e; + return ret; } - return events.map( - (e) => { - let ret = this._getTilesForEvent(pEvent, e); - pEvent = e; - return ret; - } - ).reduce((a,b) => a.concat(b)); - }; + ).reduce((a,b) => a.concat(b)); - let eventTiles = renderEvents(prevEvent, summarisedEvents); + if (eventTiles.length === 0) { + eventTiles = null; + } ret.push( {eventTiles} ); - // Set previous event to last MembershipChange - prevEvent = this.props.events[i - 1]; continue; }