From 7e88f0083ddf9c68cd389448a3bd5689b7be2c1d Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 16 Nov 2016 16:26:24 +0000 Subject: [PATCH] Fix more join-part collapsing regressions Use the previous content of the first event known for a user in a block of membership changes. This means single events are not special cased. --- .../views/elements/MemberEventListSummary.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/views/elements/MemberEventListSummary.js b/src/components/views/elements/MemberEventListSummary.js index b460a3513e..69bcd7c203 100644 --- a/src/components/views/elements/MemberEventListSummary.js +++ b/src/components/views/elements/MemberEventListSummary.js @@ -156,21 +156,21 @@ module.exports = React.createClass({ let senders = new Set(eventsToRender.map((e) => e.getSender())); senders.forEach( (userId) => { - // Only push the last event if it isn't the same membership as the first - let userEvents = eventsToRender.filter((e) => { return e.getSender() === userId; }); - if (userEvents.length === 1) { - filteredEvents.push(userEvents[0]); - return; - } - + // NB: These may be the same event, in which case the lastEvent is used + // because prev_content should != content let firstEvent = userEvents[0]; let lastEvent = userEvents[userEvents.length - 1]; - if (firstEvent.getContent().membership === lastEvent.getContent().membership) { + // Membership BEFORE eventsToRender + let previousMembership = firstEvent.getPrevContent().membership || "leave"; + + // Otherwise, if the last membership event differs from previousMembership, + // use that. + if (previousMembership !== lastEvent.getContent().membership) { filteredEvents.push(lastEvent); } }