diff --git a/app/components/post_list/post/header/header.tsx b/app/components/post_list/post/header/header.tsx index 44ec84ba7..b056efb79 100644 --- a/app/components/post_list/post/header/header.tsx +++ b/app/components/post_list/post/header/header.tsx @@ -42,6 +42,7 @@ type HeaderProps = { showPostPriority: boolean; shouldRenderReplyButton?: boolean; teammateNameDisplay: string; + hideGuestTags: boolean; } const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { @@ -74,7 +75,7 @@ const Header = (props: HeaderProps) => { const { author, commentCount = 0, currentUser, enablePostUsernameOverride, isAutoResponse, isCRTEnabled, isCustomStatusEnabled, isEphemeral, isMilitaryTime, isPendingOrFailed, isSystemPost, isTimezoneEnabled, isWebHook, - location, post, rootPostAuthor, showPostPriority, shouldRenderReplyButton, teammateNameDisplay, + location, post, rootPostAuthor, showPostPriority, shouldRenderReplyButton, teammateNameDisplay, hideGuestTags, } = props; const theme = useTheme(); const style = getStyleSheet(theme); @@ -111,7 +112,7 @@ const Header = (props: HeaderProps) => { } { if (isAutomation) { return ( @@ -31,7 +31,7 @@ const HeaderTag = ({ testID='post_header.bot.tag' /> ); - } else if (isGuest) { + } else if (showGuestTag) { return ( ({ author: observeUser(database, post.userId), + hideGuestTags: observeConfigBooleanValue(database, 'HideGuestTags'), })); export default withDatabase(enhance(SystemMessage)); diff --git a/app/components/post_list/post/system_message/system_message.tsx b/app/components/post_list/post/system_message/system_message.tsx index a90d95253..479253c39 100644 --- a/app/components/post_list/post/system_message/system_message.tsx +++ b/app/components/post_list/post/system_message/system_message.tsx @@ -6,6 +6,7 @@ import {type IntlShape, useIntl} from 'react-intl'; import {type StyleProp, Text, type TextStyle, View, type ViewStyle} from 'react-native'; import Markdown from '@components/markdown'; +import {postTypeMessages} from '@components/post_list/combined_user_activity/messages'; import {Post} from '@constants'; import {useTheme} from '@context/theme'; import {t} from '@i18n'; @@ -221,7 +222,7 @@ const renderUnarchivedMessage = ({post, author, location, styles, intl, theme}: return renderMessage({post, styles, intl, location, localeHolder, values, theme}); }; -const renderAddGuestToChannelMessage = ({post, location, styles, intl, theme}: RenderersProps) => { +const renderAddGuestToChannelMessage = ({post, location, styles, intl, theme}: RenderersProps, hideGuestTags: boolean) => { if (!post.props.username || !post.props.addedUsername) { return null; } @@ -229,27 +230,27 @@ const renderAddGuestToChannelMessage = ({post, location, styles, intl, theme}: R const username = renderUsername(post.props.username); const addedUsername = renderUsername(post.props.addedUsername); - const localeHolder = { + const localeHolder = hideGuestTags ? postTypeMessages[Post.POST_TYPES.ADD_TO_CHANNEL].one : { id: t('api.channel.add_guest.added'), defaultMessage: '{addedUsername} added to the channel as a guest by {username}.', }; - const values = {username, addedUsername}; + const values = hideGuestTags ? {firstUser: addedUsername, actor: username} : {username, addedUsername}; return renderMessage({post, styles, intl, location, localeHolder, values, theme}); }; -const renderGuestJoinChannelMessage = ({post, styles, location, intl, theme}: RenderersProps) => { +const renderGuestJoinChannelMessage = ({post, styles, location, intl, theme}: RenderersProps, hideGuestTags: boolean) => { if (!post.props.username) { return null; } const username = renderUsername(post.props.username); - const localeHolder = { + const localeHolder = hideGuestTags ? postTypeMessages[Post.POST_TYPES.JOIN_CHANNEL].one : { id: t('api.channel.guest_join_channel.post_and_forget'), defaultMessage: '{username} joined the channel as a guest.', }; - const values = {username}; + const values = hideGuestTags ? {firstUser: username} : {username}; return renderMessage({post, styles, intl, location, localeHolder, values, theme}); }; @@ -259,17 +260,22 @@ const systemMessageRenderers = { [Post.POST_TYPES.PURPOSE_CHANGE]: renderPurposeChangeMessage, [Post.POST_TYPES.CHANNEL_DELETED]: renderArchivedMessage, [Post.POST_TYPES.CHANNEL_UNARCHIVED]: renderUnarchivedMessage, - [Post.POST_TYPES.GUEST_JOIN_CHANNEL]: renderGuestJoinChannelMessage, - [Post.POST_TYPES.ADD_GUEST_TO_CHANNEL]: renderAddGuestToChannelMessage, }; -export const SystemMessage = ({post, location, author}: SystemMessageProps) => { +export const SystemMessage = ({post, location, author, hideGuestTags}: SystemMessageProps & { hideGuestTags: boolean}) => { const intl = useIntl(); const theme = useTheme(); const style = getStyleSheet(theme); const textStyles = getMarkdownTextStyles(theme); const styles = {messageStyle: style.systemMessage, textStyles, containerStyle: style.container}; + if (post.type === Post.POST_TYPES.GUEST_JOIN_CHANNEL) { + return renderGuestJoinChannelMessage({post, author, location, styles, intl, theme}, hideGuestTags); + } + if (post.type === Post.POST_TYPES.ADD_GUEST_TO_CHANNEL) { + return renderAddGuestToChannelMessage({post, author, location, styles, intl, theme}, hideGuestTags); + } + const renderer = systemMessageRenderers[post.type]; if (!renderer) { return ( diff --git a/app/components/user_item/index.ts b/app/components/user_item/index.ts index df41e980b..a21272660 100644 --- a/app/components/user_item/index.ts +++ b/app/components/user_item/index.ts @@ -26,6 +26,7 @@ const enhanced = withObservables([], ({database}: WithDatabaseArgs) => { currentUserId, locale, teammateNameDisplay, + hideGuestTags: observeConfigBooleanValue(database, 'HideGuestTags'), }; }); diff --git a/app/components/user_item/user_item.tsx b/app/components/user_item/user_item.tsx index 6af46a5ca..d3cf1e411 100644 --- a/app/components/user_item/user_item.tsx +++ b/app/components/user_item/user_item.tsx @@ -17,7 +17,7 @@ import {displayUsername, getUserCustomStatus, isBot, isCustomStatusExpired, isGu import type UserModel from '@typings/database/models/servers/user'; -type AtMentionItemProps = { +type Props = { FooterComponent?: ReactNode; user: UserProfile | UserModel; containerStyle?: StyleProp; @@ -35,6 +35,7 @@ type AtMentionItemProps = { disabled?: boolean; viewRef?: React.LegacyRef; padding?: number; + hideGuestTags: boolean; } const getThemedStyles = makeStyleSheetFromTheme((theme: Theme) => { @@ -107,7 +108,8 @@ const UserItem = ({ viewRef, padding, includeMargin, -}: AtMentionItemProps) => { + hideGuestTags, +}: Props) => { const theme = useTheme(); const style = getThemedStyles(theme); const intl = useIntl(); @@ -198,7 +200,7 @@ const UserItem = ({ style={nonThemedStyles.tag} /> )} - {showBadges && guest && ( + {showBadges && guest && !hideGuestTags && ( ({ @@ -47,7 +48,11 @@ const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ }, })); -const DirectMessage = ({displayName, user}: Props) => { +const DirectMessage = ({ + displayName, + user, + hideGuestTags, +}: Props) => { const theme = useTheme(); const styles = getStyleSheet(theme); const directMessageUserTestId = `channel_info.title.direct_message.${user?.id}`; @@ -74,7 +79,7 @@ const DirectMessage = ({displayName, user}: Props) => { > {displayName} - {user?.isGuest && + {user?.isGuest && !hideGuestTags && ({ const UserProfileTitle = ({ enablePostIconOverride, enablePostUsernameOverride, headerText, imageSize, isChannelAdmin, isSystemAdmin, isTeamAdmin, - teammateDisplayName, user, userIconOverride, usernameOverride, + teammateDisplayName, user, userIconOverride, usernameOverride, hideGuestTags, }: Props) => { const galleryIdentifier = `${user.id}-avatarPreview`; const intl = useIntl(); @@ -155,7 +156,7 @@ const UserProfileTitle = ({ diff --git a/app/screens/user_profile/title/tag.tsx b/app/screens/user_profile/title/tag.tsx index ec85013ab..6cdc2a4c4 100644 --- a/app/screens/user_profile/title/tag.tsx +++ b/app/screens/user_profile/title/tag.tsx @@ -9,7 +9,7 @@ import Tag, {BotTag, GuestTag} from '@components/tag'; type Props = { isBot: boolean; isChannelAdmin: boolean; - isGuest: boolean; + showGuestTag: boolean; isSystemAdmin: boolean; isTeamAdmin: boolean; } @@ -22,7 +22,7 @@ const styles = StyleSheet.create({ }, }); -const UserProfileTag = ({isBot, isChannelAdmin, isGuest, isSystemAdmin, isTeamAdmin}: Props) => { +const UserProfileTag = ({isBot, isChannelAdmin, showGuestTag, isSystemAdmin, isTeamAdmin}: Props) => { if (isBot) { return ( ); } - if (isGuest) { + if (showGuestTag) { return ( { const {formatMessage, locale} = useIntl(); const serverUrl = useServerUrl(); @@ -175,6 +177,7 @@ const UserProfile = ({ user={user} userIconOverride={userIconOverride} usernameOverride={usernameOverride} + hideGuestTags={hideGuestTags} /> {showUserProfileOptions &&