diff --git a/lib/shared/reaction-utils.js b/lib/shared/reaction-utils.js --- a/lib/shared/reaction-utils.js +++ b/lib/shared/reaction-utils.js @@ -14,9 +14,11 @@ invariant(reactionInfo, 'reactionInfo should be set'); reactionText.push(reaction); - if (reactionInfo.users.size > 1) { - reactionText.push(reactionInfo.users.size); + const { size: numberOfReacts } = reactionInfo.users; + if (numberOfReacts <= 1) { + continue; } + reactionText.push(numberOfReacts > 9 ? '9+' : numberOfReacts.toString()); } return reactionText.join(' '); diff --git a/lib/shared/reaction-utils.test.js b/lib/shared/reaction-utils.test.js --- a/lib/shared/reaction-utils.test.js +++ b/lib/shared/reaction-utils.test.js @@ -110,5 +110,36 @@ expect(stringForReactionList(reactionsMap)).toBe('👍 😆 3'); }, ); + + it( + 'should return (👍 9+) for a message with 12 user likes' + + ' not including the viewer', + () => { + const messageLikesUsers = [ + '86622', + '12345', + '67890', + '83889', + '49203', + '12932', + '83029', + '72902', + '49022', + '48902', + '80922', + '12890', + ]; + const messageLikesUsersSet = new Set(messageLikesUsers); + const messageLikesInfo = { + users: messageLikesUsersSet, + viewerReacted: false, + }; + + const reactionsMap = new Map(); + reactionsMap.set('👍', messageLikesInfo); + + expect(stringForReactionList(reactionsMap)).toBe('👍 9+'); + }, + ); }, );