Skip to content

Commit

Permalink
Remove more dangling properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tassoevan committed Dec 29, 2022
1 parent b152155 commit 8983d19
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
16 changes: 12 additions & 4 deletions apps/meteor/client/components/message/variants/RoomMessage.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand All @@ -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 {
Expand All @@ -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'
>
<MessageLeftContainer>
{!sequential && message.u.username && !selecting && (
Expand All @@ -71,7 +79,7 @@ const RoomMessage = ({ message, sequential, all, mention, unread, ...props }: Ro
{ignored ? (
<IgnoredContent onShowMessageIgnored={toggleIgnoring} />
) : (
<RoomMessageContent id={message._id} message={message} unread={unread} mention={mention} all={all} sequential={sequential} />
<RoomMessageContent message={message} subscription={subscription} unread={unread} mention={mention} all={all} />
)}
</MessageContainer>
{!message.private && <Toolbox message={message} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<IThreadMessage | IThreadMainMessage>;
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 },
Expand Down
13 changes: 2 additions & 11 deletions apps/meteor/client/views/room/MessageList/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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;
Expand All @@ -64,24 +62,17 @@ export const MessageList = ({ rid }: MessageListProps): ReactElement => {

{visible && (
<RoomMessage
sequential={shouldShowAsSequential}
message={message}
subscription={subscription}
sequential={shouldShowAsSequential}
unread={unread}
mention={mention}
all={all}
data-id={message._id}
data-system-message={Boolean(message.t)}
data-mid={message._id}
data-unread={firstUnread}
data-sequential={sequential}
data-own={own}
data-qa-type='message'
/>
)}

{isThreadMessage(message) && (
<ThreadMessagePreview
data-system-message={Boolean(message.t)}
data-mid={message._id}
data-tmid={message.tmid}
data-unread={firstUnread}
Expand Down

0 comments on commit 8983d19

Please sign in to comment.