[FIX] `You and @yourUsername reacted with`title on reactions (#25733)

<!-- This is a pull request template, you do not need to uncomment or remove the comments, they won't show up in the PR text. -->

<!-- Your Pull Request name should start with one of the following tags
  [NEW] For new features
  [IMPROVE] For an improvement (performance or little improvements) in existing features
  [FIX] For bug fixes that affect the end-user
  [BREAK] For pull requests including breaking changes
  Chore: For small tasks
  Doc: For documentation
-->

<!-- Checklist!!! If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code. 
  - I have read the Contributing Guide - https://github.com/RocketChat/Rocket.Chat/blob/develop/.github/CONTRIBUTING.md#contributing-to-rocketchat doc
  - I have signed the CLA - https://cla-assistant.io/RocketChat/Rocket.Chat
  - Lint and unit tests pass locally with my changes
  - I have added tests that prove my fix is effective or that my feature works (if applicable)
  - I have added necessary documentation (if applicable)
  - Any dependent changes have been merged and published in downstream modules
-->

## Proposed changes (including videos or screenshots)
<!-- CHANGELOG -->
<!--
  Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request.
  If it fixes a bug or resolves a feature request, be sure to link to that issue below.
  This description will appear in the release notes if we accept the contribution.
-->

<!-- END CHANGELOG -->

## Issue(s)
<!-- Link the issues being closed by or related to this PR. For example, you can use #594 if this PR closes issue number 594 -->

## Steps to test or reproduce
<!-- Mention how you would reproduce the bug if not mentioned on the issue page already. Also mention which screens are going to have the changes if applicable -->

## Further comments
<!-- If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc... -->
pull/25848/head
gabriellsh 4 years ago committed by GitHub
parent 83851a0ad5
commit d2b214f19f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      apps/meteor/client/views/room/MessageList/components/MessageReaction.tsx
  2. 4
      apps/meteor/client/views/room/MessageList/providers/MessageListProvider.tsx

@ -4,21 +4,7 @@ import React, { FC, useRef } from 'react';
import { getEmojiClassNameAndDataTitle } from '../../../../lib/utils/renderEmoji';
type TranslationRepliesKey =
| 'You_have_reacted'
| 'Users_and_more_reacted_with'
| 'You_and_more_Reacted_with'
| 'You_users_and_more_Reacted_with'
| 'Users_reacted_with'
| 'You_and_users_Reacted_with';
// "You": "You",
// "You_user_have_reacted": "You have reacted",
// "Users_and_more_reacted_with": "__users__ and __count__ more have reacted with __emoji__",
// "You_and_more_Reacted_with": "You, __users__ and __count__ more have reacted with __emoji__",
// "You_and_Reacted_with": "You and __count__ more have reacted with __emoji__",
const getTranslationKey = (users: string[], mine: boolean): TranslationRepliesKey => {
const getTranslationKey = (users: string[], mine: boolean): TranslationKey => {
if (users.length === 0) {
if (mine) {
return 'You_have_reacted';
@ -27,7 +13,7 @@ const getTranslationKey = (users: string[], mine: boolean): TranslationRepliesKe
if (users.length > 15) {
if (mine) {
return 'You_and_more_Reacted_with';
return 'You_users_and_more_Reacted_with';
}
return 'Users_and_more_reacted_with';
}
@ -68,7 +54,7 @@ export const MessageReaction: FC<{
ref.current &&
openTooltip(
<>
{t(key as TranslationKey, {
{t(key, {
counter: names.length,
users: names.join(', '),
emoji: name,

@ -48,7 +48,7 @@ export const MessageListProvider: FC<{
return [];
}
if (!isMessageReactionsNormalized(message)) {
return (message.reactions && message.reactions[reaction]?.usernames.map((username) => `@${username}`)) || [];
return message.reactions?.[reaction]?.usernames.filter((user) => user !== username).map((username) => `@${username}`) || [];
}
if (!username) {
return message.reactions[reaction].names;
@ -64,7 +64,7 @@ export const MessageListProvider: FC<{
useUserHasReacted: username
? (message) =>
(reaction): boolean =>
Boolean(message.reactions && message.reactions[reaction].usernames.includes(username))
Boolean(message.reactions?.[reaction].usernames.includes(username))
: () => (): boolean => false,
useShowFollowing: uid
? ({ message }): boolean => Boolean(message.replies && message.replies.indexOf(uid) > -1)

Loading…
Cancel
Save