From 25919131fced007b2932cd12b0306321086f18e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Espino=20Garc=C3=ADa?= Date: Wed, 22 Jan 2025 13:12:59 +0100 Subject: [PATCH] Fix styles for add people ephemeral message (#8494) --- .../post/body/add_members/add_members.tsx | 66 +++++++++---------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/app/components/post_list/post/body/add_members/add_members.tsx b/app/components/post_list/post/body/add_members/add_members.tsx index c9a0247b2..40d8af809 100644 --- a/app/components/post_list/post/body/add_members/add_members.tsx +++ b/app/components/post_list/post/body/add_members/add_members.tsx @@ -2,7 +2,7 @@ // See LICENSE.txt for license information. import React, {type ReactNode} from 'react'; -import {useIntl} from 'react-intl'; +import {defineMessages, useIntl} from 'react-intl'; import {Text} from 'react-native'; import {removePost, sendAddToChannelEphemeralPost} from '@actions/local/post'; @@ -11,7 +11,6 @@ import FormattedText from '@components/formatted_text'; import AtMention from '@components/markdown/at_mention'; import {General} from '@constants'; import {useServerUrl} from '@context/server'; -import {t} from '@i18n'; import {getMarkdownTextStyles} from '@utils/markdown'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import {isStringArray} from '@utils/types'; @@ -70,6 +69,29 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { }; }); +const definedMessages = defineMessages({ + linkIdPrivate: { + id: 'post_body.check_for_out_of_channel_mentions.link.private', + defaultMessage: 'add them to this private channel', + }, + linkIdPublic: { + id: 'post_body.check_for_out_of_channel_mentions.link.public', + defaultMessage: 'add them to the channel', + }, + messageOne: { + id: 'post_body.check_for_out_of_channel_mentions.message.one', + defaultMessage: '{username} was mentioned but is not in the channel. Would you like to ', + }, + messageMultiple: { + id: 'post_body.check_for_out_of_channel_mentions.message.multiple', + defaultMessage: '{usernames} were mentioned but they are not in the channel. Would you like to ', + }, + outOfGroupsMessage: { + id: 'post_body.check_for_out_of_channel_groups_mentions.message', + defaultMessage: 'did not get notified by this mention because they are not in the channel. They are also not a member of the groups linked to this channel.', + }, +}); + const AddMembers = ({channelType, currentUser, location, post, theme}: AddMembersProps) => { const intl = useIntl(); const styles = getStyleSheet(theme); @@ -166,45 +188,20 @@ const AddMembers = ({channelType, currentUser, location, post, theme}: AddMember return ''; }; - let linkId = ''; - let linkText = ''; - if (channelType === General.PRIVATE_CHANNEL) { - linkId = t('post_body.check_for_out_of_channel_mentions.link.private'); - linkText = 'add them to this private channel'; - } else if (channelType === General.OPEN_CHANNEL) { - linkId = t('post_body.check_for_out_of_channel_mentions.link.public'); - linkText = 'add them to the channel'; - } - - let outOfChannelMessageID = ''; - let outOfChannelMessageText = ''; + const linkMessageDescriptor = channelType === General.PRIVATE_CHANNEL ? definedMessages.linkIdPrivate : definedMessages.linkIdPublic; + const outOfChannelMessageDescriptor = usernames.length === 1 ? definedMessages.messageOne : definedMessages.messageMultiple; const outOfChannelAtMentions = generateAtMentions(usernames); - if (usernames.length === 1) { - outOfChannelMessageID = t('post_body.check_for_out_of_channel_mentions.message.one'); - outOfChannelMessageText = 'was mentioned but is not in the channel. Would you like to '; - } else if (usernames.length > 1) { - outOfChannelMessageID = t('post_body.check_for_out_of_channel_mentions.message.multiple'); - outOfChannelMessageText = 'were mentioned but they are not in the channel. Would you like to '; - } - let outOfGroupsMessageID = ''; - let outOfGroupsMessageText = ''; const outOfGroupsAtMentions = generateAtMentions(noGroupsUsernames); - if (noGroupsUsernames?.length) { - outOfGroupsMessageID = t('post_body.check_for_out_of_channel_groups_mentions.message'); - outOfGroupsMessageText = 'did not get notified by this mention because they are not in the channel. They are also not a member of the groups linked to this channel.'; - } let outOfChannelMessage = null; if (usernames.length) { outOfChannelMessage = ( - + {outOfChannelAtMentions} {' '} ); @@ -232,8 +227,7 @@ const AddMembers = ({channelType, currentUser, location, post, theme}: AddMember {outOfGroupsAtMentions} {' '}