From 6b2aa43b712e0fb247571916de24f494e4d0789b Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 10 Nov 2016 14:33:41 +0000 Subject: [PATCH] Factor out "and others" --- .../views/elements/MemberEventListSummary.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/views/elements/MemberEventListSummary.js b/src/components/views/elements/MemberEventListSummary.js index e141a32671..af067dba4b 100644 --- a/src/components/views/elements/MemberEventListSummary.js +++ b/src/components/views/elements/MemberEventListSummary.js @@ -85,19 +85,22 @@ module.exports = React.createClass({ // name1, name2, name3 [and 100 others] names += ', '; } - return names + this._getEventSenderName(lastEvent); + + let remaining = originalNumber - this.props.summaryLength; + let remainingDesc = (remaining > 0 ? 'and ' + remaining + ' others ':''); + + return names + this._getEventSenderName(lastEvent) + remainingDesc; }, _renderSummary: function(joinEvents, leaveEvents) { let joiners = this._renderNameList(joinEvents); - let remainingJoiners = joinEvents.length - this.props.summaryLength; let leavers = this._renderNameList(leaveEvents); - let remainingLeavers = leaveEvents.length - this.props.summaryLength; + let joinSummary = null; if (joiners) { joinSummary = ( - {joiners} {remainingJoiners > 0 ? 'and ' + remainingJoiners + ' others ':''}joined the room + {joiners} joined the room ); } @@ -105,7 +108,7 @@ module.exports = React.createClass({ if (leavers) { leaveSummary = ( - {leavers} {remainingLeavers > 0 ? 'and ' + remainingLeavers + ' others ':''}left the room + {leavers} left the room ); }