[Perf] Message: Do not depend on sender when not needed

This commit is contained in:
Alexander Zinchuk 2023-02-04 03:02:46 +01:00
parent 07b8e2ba6a
commit 357eef783b

View File

@ -84,6 +84,7 @@ import {
getMessageSingleCustomEmoji, getMessageSingleCustomEmoji,
hasMessageText, hasMessageText,
isChatGroup, isChatGroup,
getMessageLocation,
} from '../../../global/helpers'; } from '../../../global/helpers';
import buildClassName from '../../../util/buildClassName'; import buildClassName from '../../../util/buildClassName';
import { import {
@ -1289,11 +1290,12 @@ export default memo(withGlobal<OwnProps>(
const messageTopic = hasTopicChip ? (selectTopicFromMessage(global, message) || chat?.topics?.[GENERAL_TOPIC_ID]) const messageTopic = hasTopicChip ? (selectTopicFromMessage(global, message) || chat?.topics?.[GENERAL_TOPIC_ID])
: undefined; : undefined;
const isLocation = Boolean(getMessageLocation(message));
return { return {
theme: selectTheme(global), theme: selectTheme(global),
chatUsernames, chatUsernames,
forceSenderName, forceSenderName,
sender,
canShowSender, canShowSender,
originSender, originSender,
botSender, botSender,
@ -1335,9 +1337,6 @@ export default memo(withGlobal<OwnProps>(
defaultReaction: isMessageLocal(message) ? undefined : selectDefaultReaction(global, chatId), defaultReaction: isMessageLocal(message) ? undefined : selectDefaultReaction(global, chatId),
activeReactions: reactionMessage && activeReactions[reactionMessage.id], activeReactions: reactionMessage && activeReactions[reactionMessage.id],
activeEmojiInteractions, activeEmojiInteractions,
...(isOutgoing && { outgoingStatus: selectOutgoingStatus(global, message, messageListType === 'scheduled') }),
...(typeof uploadProgress === 'number' && { uploadProgress }),
...(isFocused && { focusDirection, noFocusHighlight, isResizingContainer }),
hasUnreadReaction, hasUnreadReaction,
isTranscribing: transcriptionId !== undefined && global.transcriptions[transcriptionId]?.isPending, isTranscribing: transcriptionId !== undefined && global.transcriptions[transcriptionId]?.isPending,
transcribedText: transcriptionId !== undefined ? global.transcriptions[transcriptionId]?.text : undefined, transcribedText: transcriptionId !== undefined ? global.transcriptions[transcriptionId]?.text : undefined,
@ -1347,6 +1346,10 @@ export default memo(withGlobal<OwnProps>(
messageTopic, messageTopic,
genericEffects: global.genericEmojiEffects, genericEffects: global.genericEmojiEffects,
hasTopicChip, hasTopicChip,
...((canShowSender || isLocation) && { sender }),
...(isOutgoing && { outgoingStatus: selectOutgoingStatus(global, message, messageListType === 'scheduled') }),
...(typeof uploadProgress === 'number' && { uploadProgress }),
...(isFocused && { focusDirection, noFocusHighlight, isResizingContainer }),
}; };
}, },
)(Message)); )(Message));