From a3a440e289022c6fbbc788f8731dabecab6e1df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Vinad=C3=A9?= Date: Wed, 24 Oct 2018 01:53:13 -0300 Subject: [PATCH] [IMPROVE] Limit the number of typing users shown (#8722) It limits the number of usernames shown above the textbox when people are typing. If the number of typing users isn't greater than 4, then the text will show all usernames: `username1, username2, username3 and username4 are typing` But, if the number of typing users is greater than 4, then the last username will be replaced by `others`, like this: `username1, username2, username3 and others are typing` The number 4 was chosen because it was already in the code --- packages/rocketchat-ui-message/client/messageBox.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/rocketchat-ui-message/client/messageBox.js b/packages/rocketchat-ui-message/client/messageBox.js index 5c482873265e..469b01f4c65c 100644 --- a/packages/rocketchat-ui-message/client/messageBox.js +++ b/packages/rocketchat-ui-message/client/messageBox.js @@ -223,6 +223,7 @@ Template.messageBox.helpers({ }, /* globals MsgTyping*/ usersTyping() { + const maxUsernames = 4; const users = MsgTyping.get(this._id); if (users.length === 0) { return; @@ -235,10 +236,10 @@ Template.messageBox.helpers({ }; } let last = users.pop(); - if (users.length > 4) { + if (users.length >= maxUsernames) { last = t('others'); } - let usernames = users.join(', '); + let usernames = users.slice(0, maxUsernames - 1).join(', '); usernames = [usernames, last]; return { multi: true,