Skip to content

Commit

Permalink
Regression: Show username and real name on the message system (Rocket…
Browse files Browse the repository at this point in the history
  • Loading branch information
Filipe Marins committed Apr 20, 2022
1 parent b06802b commit fcbb58c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ const MessageHeader: FC<{ message: IMessage }> = ({ message }) => {
title={!showUsername && !usernameAndRealNameAreSame ? `@${user.username}` : undefined}
data-username={user.username}
onClick={user.username !== undefined ? openUserCard(user.username) : undefined}
style={{ cursor: 'pointer' }}
>
{getUserDisplayName(user.name, user.username, showRealName)}
</MessageName>
{showUsername && (
<MessageUsername data-username={user.username} onClick={user.username !== undefined ? openUserCard(user.username) : undefined}>
<MessageUsername
data-username={user.username}
onClick={user.username !== undefined ? openUserCard(user.username) : undefined}
style={{ cursor: 'pointer' }}
>
@{user.username}
</MessageUsername>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
MessageSystemName,
MessageSystemTimestamp,
MessageSystemBlock,
MessageUsername,
} from '@rocket.chat/fuselage';
import React, { FC, memo } from 'react';

Expand All @@ -15,14 +16,23 @@ import Attachments from '../../../../components/Message/Attachments';
import MessageActions from '../../../../components/Message/MessageActions';
import UserAvatar from '../../../../components/avatar/UserAvatar';
import { TranslationKey, useTranslation } from '../../../../contexts/TranslationContext';
import { useUserData } from '../../../../hooks/useUserData';
import { getUserDisplayName } from '../../../../lib/getUserDisplayName';
import { UserPresence } from '../../../../lib/presence';
import { useMessageActions, useMessageRunActionLink } from '../../contexts/MessageContext';
import { useMessageListShowRealName } from '../contexts/MessageListContext';
import { useMessageListShowRealName, useMessageListShowUsername } from '../contexts/MessageListContext';

export const MessageSystem: FC<{ message: IMessage }> = ({ message }) => {
const t = useTranslation();
const { formatters } = useMessageActions();
const {
actions: { openUserCard },
formatters,
} = useMessageActions();
const runActionLink = useMessageRunActionLink();
const showUsername = useMessageListShowRealName();
const showRealName = useMessageListShowRealName();
const user: UserPresence = { ...message.u, roles: [], ...useUserData(message.u._id) };
const usernameAndRealNameAreSame = !user.name || user.username === user.name;
const showUsername = useMessageListShowUsername() && showRealName && !usernameAndRealNameAreSame;

const messageType = MessageTypes.getType(message);

Expand All @@ -33,7 +43,18 @@ export const MessageSystem: FC<{ message: IMessage }> = ({ message }) => {
</MessageSystemLeftContainer>
<MessageSystemContainer>
<MessageSystemBlock>
<MessageSystemName>{(showUsername && message.u.name) || message.u.username}</MessageSystemName>
<MessageSystemName onClick={user.username !== undefined ? openUserCard(user.username) : undefined} style={{ cursor: 'pointer' }}>
{getUserDisplayName(user.name, user.username, showRealName)}
</MessageSystemName>
{showUsername && (
<MessageUsername
data-username={user.username}
onClick={user.username !== undefined ? openUserCard(user.username) : undefined}
style={{ cursor: 'pointer' }}
>
@{user.username}
</MessageUsername>
)}
{messageType && (
<MessageSystemBody
dangerouslySetInnerHTML={{
Expand Down

0 comments on commit fcbb58c

Please sign in to comment.