From 5d6a0305b219403e270333f2e8954b577f440607 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 3 Aug 2021 19:03:17 +0300 Subject: [PATCH] [Perf] [Refactoring] Fix incorrect parsing of object conditional properties --- src/components/left/main/Chat.tsx | 6 +++--- src/components/left/main/ChatList.tsx | 4 ++-- src/components/left/search/ChatMessage.tsx | 2 +- src/components/middle/MessageList.tsx | 2 +- src/components/middle/message/Message.tsx | 6 +++--- src/components/right/Profile.tsx | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/left/main/Chat.tsx b/src/components/left/main/Chat.tsx index ec99efb6..939bf31c 100644 --- a/src/components/left/main/Chat.tsx +++ b/src/components/left/main/Chat.tsx @@ -344,10 +344,7 @@ export default memo(withGlobal( chat, isMuted: selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)), lastMessageSender, - ...(isOutgoing && { lastMessageOutgoingStatus: selectOutgoingStatus(global, chat.lastMessage) }), - ...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }), actionTargetUserIds, - ...(actionTargetUserIds && { usersById }), actionTargetChatId, actionTargetMessage, draft: selectDraft(global, chatId, MAIN_THREAD_ID), @@ -355,6 +352,9 @@ export default memo(withGlobal( isSelected, canScrollDown: isSelected && messageListType === 'thread', lastSyncTime: global.lastSyncTime, + ...(isOutgoing && { lastMessageOutgoingStatus: selectOutgoingStatus(global, chat.lastMessage) }), + ...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }), + ...(actionTargetUserIds && { usersById }), }; }, (setGlobal, actions): DispatchProps => pick(actions, [ diff --git a/src/components/left/main/ChatList.tsx b/src/components/left/main/ChatList.tsx index 4b9f13ee..4d231285 100644 --- a/src/components/left/main/ChatList.tsx +++ b/src/components/left/main/ChatList.tsx @@ -231,14 +231,14 @@ export default memo(withGlobal( chatsById, usersById, lastSyncTime, + notifySettings: selectNotifySettings(global), + notifyExceptions: selectNotifyExceptions(global), ...(listType ? { listIds: listIds[listType], orderedPinnedIds: orderedPinnedIds[listType], } : { chatFolder, }), - notifySettings: selectNotifySettings(global), - notifyExceptions: selectNotifyExceptions(global), }; }, (setGlobal, actions): DispatchProps => pick(actions, [ diff --git a/src/components/left/search/ChatMessage.tsx b/src/components/left/search/ChatMessage.tsx index e814d028..b759eaea 100644 --- a/src/components/left/search/ChatMessage.tsx +++ b/src/components/left/search/ChatMessage.tsx @@ -137,8 +137,8 @@ export default memo(withGlobal( return { chat, - ...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }), lastSyncTime: global.lastSyncTime, + ...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }), }; }, (setGlobal, actions): DispatchProps => pick(actions, [ diff --git a/src/components/middle/MessageList.tsx b/src/components/middle/MessageList.tsx index 2730e5c1..52e7decf 100644 --- a/src/components/middle/MessageList.tsx +++ b/src/components/middle/MessageList.tsx @@ -534,12 +534,12 @@ export default memo(withGlobal( focusingId, hasFocusHighlight, isSelectModeActive: selectIsInSelectMode(global), - ...(withLastMessageWhenPreloading && { lastMessage }), botDescription, threadTopMessageId, hasLinkedChat: chat.fullInfo && ('linkedChatId' in chat.fullInfo) ? Boolean(chat.fullInfo.linkedChatId) : undefined, + ...(withLastMessageWhenPreloading && { lastMessage }), }; }, (setGlobal, actions): DispatchProps => pick(actions, [ diff --git a/src/components/middle/message/Message.tsx b/src/components/middle/message/Message.tsx index e5d17b0a..27069a08 100644 --- a/src/components/middle/message/Message.tsx +++ b/src/components/middle/message/Message.tsx @@ -968,10 +968,7 @@ export default memo(withGlobal( isThreadTop, replyMessage, replyMessageSender, - ...(isOutgoing && { outgoingStatus: selectOutgoingStatus(global, message, messageListType === 'scheduled') }), - ...(typeof uploadProgress === 'number' && { uploadProgress }), isFocused, - ...(isFocused && { focusDirection, noFocusHighlight }), isForwarding, isChatWithSelf, isChannel, @@ -989,6 +986,9 @@ export default memo(withGlobal( shouldAutoLoadMedia: chat ? selectShouldAutoLoadMedia(global, message, chat, sender) : undefined, shouldAutoPlayMedia: selectShouldAutoPlayMedia(global, message), shouldLoopStickers: selectShouldLoopStickers(global), + ...(isOutgoing && { outgoingStatus: selectOutgoingStatus(global, message, messageListType === 'scheduled') }), + ...(typeof uploadProgress === 'number' && { uploadProgress }), + ...(isFocused && { focusDirection, noFocusHighlight }), }; }, (setGlobal, actions): DispatchProps => pick(actions, [ diff --git a/src/components/right/Profile.tsx b/src/components/right/Profile.tsx index 52bf3180..82724ec0 100644 --- a/src/components/right/Profile.tsx +++ b/src/components/right/Profile.tsx @@ -459,15 +459,15 @@ export default memo(withGlobal( areMembersHidden, canAddMembers, canDeleteMembers, - ...(hasMembersTab && members && { - members, - usersById, - }), currentUserId: global.currentUserId, isRightColumnShown: selectIsRightColumnShown(global), isRestricted: chat && chat.isRestricted, lastSyncTime: global.lastSyncTime, serverTimeOffset: global.serverTimeOffset, + ...(hasMembersTab && members && { + members, + usersById, + }), }; }, (setGlobal, actions): DispatchProps => pick(actions, [