Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] You and @yourUsername reacted withtitle on reactions #25733

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
}
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down