[Refactoring] Message: Simplify asForwarded logic
This commit is contained in:
parent
7f74b8cd99
commit
392aee6c84
@ -274,20 +274,24 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
const isScheduled = messageListType === 'scheduled' || message.isScheduled;
|
const isScheduled = messageListType === 'scheduled' || message.isScheduled;
|
||||||
const hasReply = isReplyMessage(message) && !shouldHideReply;
|
const hasReply = isReplyMessage(message) && !shouldHideReply;
|
||||||
const hasThread = Boolean(threadInfo) && messageListType === 'thread';
|
const hasThread = Boolean(threadInfo) && messageListType === 'thread';
|
||||||
|
const customShape = getMessageCustomShape(message);
|
||||||
const { forwardInfo, viaBotId } = message;
|
const { forwardInfo, viaBotId } = message;
|
||||||
const asForwarded = (
|
const asForwarded = (
|
||||||
forwardInfo && (!isChatWithSelf || isScheduled) && !isRepliesChat && !forwardInfo.isLinkedChannelPost
|
forwardInfo
|
||||||
|
&& (!isChatWithSelf || isScheduled)
|
||||||
|
&& !isRepliesChat
|
||||||
|
&& !forwardInfo.isLinkedChannelPost
|
||||||
|
&& !customShape
|
||||||
);
|
);
|
||||||
const isInDocumentGroup = Boolean(message.groupedId) && !message.isInAlbum;
|
const isInDocumentGroup = Boolean(message.groupedId) && !message.isInAlbum;
|
||||||
const isAlbum = Boolean(album) && album!.messages.length > 1;
|
const isAlbum = Boolean(album) && album!.messages.length > 1;
|
||||||
const {
|
const {
|
||||||
text, photo, video, audio, voice, document, sticker, contact, poll, webPage, invoice,
|
text, photo, video, audio, voice, document, sticker, contact, poll, webPage, invoice,
|
||||||
} = getMessageContent(message);
|
} = getMessageContent(message);
|
||||||
const customShape = getMessageCustomShape(message);
|
|
||||||
const textParts = renderMessageText(message, highlight, isEmojiOnlyMessage(customShape));
|
const textParts = renderMessageText(message, highlight, isEmojiOnlyMessage(customShape));
|
||||||
const isContextMenuShown = contextMenuPosition !== undefined;
|
const isContextMenuShown = contextMenuPosition !== undefined;
|
||||||
const signature = (
|
const signature = (
|
||||||
(isChannel && message.adminTitle) || (forwardInfo && !asForwarded && forwardInfo.adminTitle) || undefined
|
(isChannel && message.adminTitle) || (!asForwarded && forwardInfo?.adminTitle) || undefined
|
||||||
);
|
);
|
||||||
const metaSafeAuthorWidth = useMemo(() => {
|
const metaSafeAuthorWidth = useMemo(() => {
|
||||||
return signature ? calculateAuthorWidth(signature) : undefined;
|
return signature ? calculateAuthorWidth(signature) : undefined;
|
||||||
@ -473,7 +477,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
function renderContent() {
|
function renderContent() {
|
||||||
const className = buildClassName(
|
const className = buildClassName(
|
||||||
'content-inner',
|
'content-inner',
|
||||||
asForwarded && !customShape && 'forwarded-message',
|
asForwarded && 'forwarded-message',
|
||||||
hasReply && 'reply-message',
|
hasReply && 'reply-message',
|
||||||
noMediaCorners && 'no-media-corners',
|
noMediaCorners && 'no-media-corners',
|
||||||
);
|
);
|
||||||
@ -735,7 +739,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
style={style}
|
style={style}
|
||||||
dir="auto"
|
dir="auto"
|
||||||
>
|
>
|
||||||
{asForwarded && !customShape && (!isInDocumentGroup || isFirstInDocumentGroup) && (
|
{asForwarded && (!isInDocumentGroup || isFirstInDocumentGroup) && (
|
||||||
<div className="message-title">{lang('ForwardedMessage')}</div>
|
<div className="message-title">{lang('ForwardedMessage')}</div>
|
||||||
)}
|
)}
|
||||||
{renderContent()}
|
{renderContent()}
|
||||||
|
|||||||
@ -77,7 +77,7 @@ export function buildContentClassName(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asForwarded && !customShape) {
|
if (asForwarded) {
|
||||||
classNames.push('is-forwarded');
|
classNames.push('is-forwarded');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user