From 103710728f74f3c74e5ead0a65eaf59084788f5a Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 9 Feb 2017 10:30:06 +0000 Subject: [PATCH] Do not show "+1 other" Instead show a user name or avatar. --- src/WhoIsTyping.js | 8 +++++--- src/components/structures/RoomStatusBar.js | 9 ++++++--- src/components/structures/RoomView.js | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/WhoIsTyping.js b/src/WhoIsTyping.js index bff536a61e..4502b0ccd9 100644 --- a/src/WhoIsTyping.js +++ b/src/WhoIsTyping.js @@ -49,8 +49,10 @@ module.exports = { }, whoIsTypingString: function(whoIsTyping, limit) { - const othersCount = limit === undefined ? - 0 : Math.max(whoIsTyping.length - limit, 0); + let othersCount = 0; + if (whoIsTyping.length > limit) { + othersCount = whoIsTyping.length - limit + 1; + } if (whoIsTyping.length == 0) { return ''; } else if (whoIsTyping.length == 1) { @@ -61,7 +63,7 @@ module.exports = { }); if (othersCount) { const other = ' other' + (othersCount > 1 ? 's' : ''); - return names.slice(0, limit).join(', ') + ' and ' + + return names.slice(0, limit - 1).join(', ') + ' and ' + othersCount + other + ' are typing'; } else { const lastPerson = names.pop(); diff --git a/src/components/structures/RoomStatusBar.js b/src/components/structures/RoomStatusBar.js index adbfb25337..288ca0b974 100644 --- a/src/components/structures/RoomStatusBar.js +++ b/src/components/structures/RoomStatusBar.js @@ -82,7 +82,7 @@ module.exports = React.createClass({ getDefaultProps: function() { return { - whoIsTypingLimit: 2, + whoIsTypingLimit: 3, }; }, @@ -217,8 +217,11 @@ module.exports = React.createClass({ _renderTypingIndicatorAvatars: function(limit) { let users = this.state.usersTyping; - let othersCount = Math.max(users.length - limit, 0); - users = users.slice(0, limit); + let othersCount = 0; + if (users.length > limit) { + othersCount = users.length - limit + 1; + users = users.slice(0, limit - 1); + } let avatars = users.map((u, index) => { let showInitial = othersCount === 0 && index === users.length - 1; diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index a7d52019c4..432dc5b724 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -1537,7 +1537,7 @@ module.exports = React.createClass({ onResize={this.onChildResize} onVisible={this.onStatusBarVisible} onHidden={this.onStatusBarHidden} - whoIsTypingLimit={2} + whoIsTypingLimit={3} />; }