diff --git a/apps/meteor/client/components/message/variants/RoomMessage.tsx b/apps/meteor/client/components/message/variants/RoomMessage.tsx index b2141ebce285..c3dead853276 100644 --- a/apps/meteor/client/components/message/variants/RoomMessage.tsx +++ b/apps/meteor/client/components/message/variants/RoomMessage.tsx @@ -1,3 +1,4 @@ +import type { ISubscription } from '@rocket.chat/core-typings'; import { Message, MessageLeftContainer, MessageContainer, CheckBox } from '@rocket.chat/fuselage'; import { useToggle } from '@rocket.chat/fuselage-hooks'; import type { ReactElement } from 'react'; @@ -11,6 +12,7 @@ import { useIsSelectedMessage, useCountSelected, } from '../../../views/room/MessageList/contexts/SelectedMessagesContext'; +import { isOwnUserMessage } from '../../../views/room/MessageList/lib/isOwnUserMessage'; import type { MessageWithMdEnforced } from '../../../views/room/MessageList/lib/parseMessageTextToAstMarkdown'; import { useMessageActions } from '../../../views/room/contexts/MessageContext'; import UserAvatar from '../../avatar/UserAvatar'; @@ -21,13 +23,14 @@ import RoomMessageContent from './room/RoomMessageContent'; type RoomMessageProps = { message: MessageWithMdEnforced; + subscription: ISubscription | undefined; sequential: boolean; unread: boolean; mention: boolean; all: boolean; -} & Record<`data-${string}`, string>; +}; -const RoomMessage = ({ message, sequential, all, mention, unread, ...props }: RoomMessageProps): ReactElement => { +const RoomMessage = ({ message, subscription, sequential, all, mention, unread }: RoomMessageProps): ReactElement => { const editing = useIsMessageHighlight(message._id); const [ignored, toggleIgnoring] = useToggle((message as { ignored?: boolean }).ignored ?? false); const { @@ -49,7 +52,12 @@ const RoomMessage = ({ message, sequential, all, mention, unread, ...props }: Ro sequential={sequential} data-qa-editing={editing} data-qa-selected={selected} - {...props} + data-id={message._id} + data-mid={message._id} + data-unread={unread} + data-sequential={sequential} + data-own={isOwnUserMessage(message, subscription)} + data-qa-type='message' > {!sequential && message.u.username && !selecting && ( @@ -71,7 +79,7 @@ const RoomMessage = ({ message, sequential, all, mention, unread, ...props }: Ro {ignored ? ( ) : ( - + )} {!message.private && } diff --git a/apps/meteor/client/components/message/variants/SystemMessage.tsx b/apps/meteor/client/components/message/variants/SystemMessage.tsx index cfb882dba9b9..d04f390aa7a5 100644 --- a/apps/meteor/client/components/message/variants/SystemMessage.tsx +++ b/apps/meteor/client/components/message/variants/SystemMessage.tsx @@ -36,7 +36,7 @@ type SystemMessageProps = { message: IMessage; }; -export const SystemMessage = ({ message }: SystemMessageProps): ReactElement => { +const SystemMessage = ({ message }: SystemMessageProps): ReactElement => { const t = useTranslation(); const { actions: { openUserCard }, diff --git a/apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx b/apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx index 4aafd2ee319d..c668271418e2 100644 --- a/apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx +++ b/apps/meteor/client/components/message/variants/room/RoomMessageContent.tsx @@ -1,4 +1,4 @@ -import type { IMessage, ISubscription } from '@rocket.chat/core-typings'; +import type { ISubscription, IThreadMainMessage, IThreadMessage } from '@rocket.chat/core-typings'; import { isDiscussionMessage, isThreadMainMessage, isE2EEMessage } from '@rocket.chat/core-typings'; import type { TranslationKey } from '@rocket.chat/ui-contexts'; import { useTranslation, useUserId } from '@rocket.chat/ui-contexts'; @@ -24,16 +24,14 @@ import UiKitSurface from '../../content/UiKitSurface'; import UrlPreviews from '../../content/UrlPreviews'; type RoomMessageContentProps = { - message: MessageWithMdEnforced; - sequential: boolean; - subscription?: ISubscription; - id: IMessage['_id']; + message: MessageWithMdEnforced; + subscription: ISubscription | undefined; unread: boolean; mention: boolean; all: boolean; }; -const RoomMessageContent = ({ message, unread, all, mention, subscription }: RoomMessageContentProps): ReactElement => { +const RoomMessageContent = ({ message, subscription, unread, all, mention }: RoomMessageContentProps): ReactElement => { const { broadcast, actions: { openRoom, openThread, replyBroadcast }, diff --git a/apps/meteor/client/views/room/MessageList/MessageList.tsx b/apps/meteor/client/views/room/MessageList/MessageList.tsx index 6b0d251bf33b..e2e4c35a180d 100644 --- a/apps/meteor/client/views/room/MessageList/MessageList.tsx +++ b/apps/meteor/client/views/room/MessageList/MessageList.tsx @@ -16,7 +16,6 @@ import { useMessages } from './hooks/useMessages'; import { isMessageFirstUnread } from './lib/isMessageFirstUnread'; import { isMessageNewDay } from './lib/isMessageNewDay'; import { isMessageSequential } from './lib/isMessageSequential'; -import { isOwnUserMessage } from './lib/isOwnUserMessage'; import { MessageListProvider } from './providers/MessageListProvider'; type MessageListProps = { @@ -42,7 +41,6 @@ export const MessageList = ({ rid }: MessageListProps): ReactElement => { const newDay = isMessageNewDay(message, previous); const firstUnread = isMessageFirstUnread(subscription, message, previous); - const own = isOwnUserMessage(message, subscription); const showDivider = newDay || firstUnread; const shouldShowAsSequential = sequential && !newDay; @@ -64,24 +62,17 @@ export const MessageList = ({ rid }: MessageListProps): ReactElement => { {visible && ( )} {isThreadMessage(message) && (