Skip to content

Commit

Permalink
Reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchoeler committed Jun 17, 2024
1 parent 2a2f4a4 commit 8468f30
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IMessage, MessageAttachment, MessageQuoteAttachment } from '@rocket.chat/core-typings';
import { isDiscussionMessage, isThreadMainMessage, isE2EEMessage } from '@rocket.chat/core-typings';
import type { IMessage } from '@rocket.chat/core-typings';
import { isDiscussionMessage, isThreadMainMessage, isE2EEMessage, isQuoteAttachment } from '@rocket.chat/core-typings';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import { useSetting, useTranslation, useUserId } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
Expand Down Expand Up @@ -44,10 +44,6 @@ const RoomMessageContent = ({ message, unread, all, mention, searchText }: RoomM

const normalizedMessage = useNormalizedMessage(message);

function isQuoteAttachment(attachment: MessageAttachment): attachment is MessageQuoteAttachment {
return !!(attachment as MessageQuoteAttachment).author_name;
}

const quotes = normalizedMessage?.attachments?.filter(isQuoteAttachment) || [];

const attachments = normalizedMessage?.attachments?.filter((attachment) => !isQuoteAttachment(attachment)) || [];
Expand All @@ -70,7 +66,7 @@ const RoomMessageContent = ({ message, unread, all, mention, searchText }: RoomM
</>
)}

{!!attachments && <Attachments id={message.files?.[0]._id} attachments={attachments} />}
{!!attachments && <Attachments id={message.files?.[0]?._id} attachments={attachments} />}

{normalizedMessage.blocks && (
<UiKitMessageBlock rid={normalizedMessage.rid} mid={normalizedMessage._id} blocks={normalizedMessage.blocks} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IThreadMainMessage, IThreadMessage, MessageAttachment, MessageQuoteAttachment } from '@rocket.chat/core-typings';
import { isE2EEMessage } from '@rocket.chat/core-typings';
import type { IThreadMainMessage, IThreadMessage } from '@rocket.chat/core-typings';
import { isE2EEMessage, isQuoteAttachment } from '@rocket.chat/core-typings';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import { useSetting, useUserId, useTranslation } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
Expand Down Expand Up @@ -37,10 +37,6 @@ const ThreadMessageContent = ({ message }: ThreadMessageContentProps): ReactElem

const normalizedMessage = useNormalizedMessage(message);

function isQuoteAttachment(attachment: MessageAttachment): attachment is MessageQuoteAttachment {
return !!(attachment as MessageQuoteAttachment).author_name;
}

const quotes = normalizedMessage?.attachments?.filter(isQuoteAttachment) || [];

const attachments = normalizedMessage?.attachments?.filter((attachment) => !isQuoteAttachment(attachment)) || [];
Expand All @@ -62,7 +58,7 @@ const ThreadMessageContent = ({ message }: ThreadMessageContentProps): ReactElem
<UiKitMessageBlock rid={normalizedMessage.rid} mid={normalizedMessage._id} blocks={normalizedMessage.blocks} />
)}

{!!attachments && <Attachments id={message.files?.[0]._id} attachments={attachments} />}
{!!attachments && <Attachments id={message.files?.[0]?._id} attachments={attachments} />}

{oembedEnabled && !!normalizedMessage.urls?.length && <UrlPreviews urls={normalizedMessage.urls} />}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IMessage, MessageQuoteAttachment, MessageReport, MessageAttachment } from '@rocket.chat/core-typings';
import { isE2EEMessage } from '@rocket.chat/core-typings';
import type { IMessage, MessageReport, MessageAttachment } from '@rocket.chat/core-typings';
import { isE2EEMessage, isQuoteAttachment } from '@rocket.chat/core-typings';
import { Message, MessageName, MessageToolbarItem, MessageToolbarWrapper, MessageUsername } from '@rocket.chat/fuselage';
import { UserAvatar } from '@rocket.chat/ui-avatar';
import { useSetting, useTranslation } from '@rocket.chat/ui-contexts';
Expand Down Expand Up @@ -47,10 +47,6 @@ const ContextMessage = ({

const displayName = useUserDisplayName({ name, username });

function isQuoteAttachment(attachment: MessageAttachment): attachment is MessageQuoteAttachment {
return !!(attachment as MessageQuoteAttachment).author_name;
}

const quotes = message?.attachments?.filter(isQuoteAttachment) || [];

const attachments = message?.attachments?.filter((attachment: MessageAttachment) => !isQuoteAttachment(attachment)) || [];
Expand Down Expand Up @@ -85,7 +81,7 @@ const ContextMessage = ({
message.msg
)}

{!!attachments && <Attachments id={message.files?.[0]._id} attachments={attachments} />}
{!!attachments && <Attachments id={message.files?.[0]?._id} attachments={attachments} />}
{message.blocks && <UiKitMessageBlock rid={message.rid} mid={message._id} blocks={message.blocks} />}
</Message.Body>
<ReportReasonCollapsible>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IMessage, MessageAttachment, MessageQuoteAttachment } from '@rocket.chat/core-typings';
import { isQuoteAttachment, type IMessage, type MessageAttachment } from '@rocket.chat/core-typings';
import {
Message as MessageTemplate,
MessageLeftContainer,
Expand Down Expand Up @@ -43,10 +43,6 @@ const ContactHistoryMessage: FC<{
const format = useFormatDate();
const formatTime = useFormatTime();

function isQuoteAttachment(attachment: MessageAttachment): attachment is MessageQuoteAttachment {
return !!(attachment as MessageQuoteAttachment).author_name;
}

const quotes = message?.attachments?.filter(isQuoteAttachment) || [];

const attachments = message?.attachments?.filter((attachment: MessageAttachment) => !isQuoteAttachment(attachment)) || [];
Expand Down

0 comments on commit 8468f30

Please sign in to comment.