[Perf] [Refactoring] Fix incorrect parsing of object conditional properties

This commit is contained in:
Alexander Zinchuk 2021-08-03 19:03:17 +03:00
parent a9eaa1a6d4
commit 5d6a0305b2
6 changed files with 14 additions and 14 deletions

View File

@ -344,10 +344,7 @@ export default memo(withGlobal<OwnProps>(
chat, chat,
isMuted: selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)), isMuted: selectIsChatMuted(chat, selectNotifySettings(global), selectNotifyExceptions(global)),
lastMessageSender, lastMessageSender,
...(isOutgoing && { lastMessageOutgoingStatus: selectOutgoingStatus(global, chat.lastMessage) }),
...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }),
actionTargetUserIds, actionTargetUserIds,
...(actionTargetUserIds && { usersById }),
actionTargetChatId, actionTargetChatId,
actionTargetMessage, actionTargetMessage,
draft: selectDraft(global, chatId, MAIN_THREAD_ID), draft: selectDraft(global, chatId, MAIN_THREAD_ID),
@ -355,6 +352,9 @@ export default memo(withGlobal<OwnProps>(
isSelected, isSelected,
canScrollDown: isSelected && messageListType === 'thread', canScrollDown: isSelected && messageListType === 'thread',
lastSyncTime: global.lastSyncTime, lastSyncTime: global.lastSyncTime,
...(isOutgoing && { lastMessageOutgoingStatus: selectOutgoingStatus(global, chat.lastMessage) }),
...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }),
...(actionTargetUserIds && { usersById }),
}; };
}, },
(setGlobal, actions): DispatchProps => pick(actions, [ (setGlobal, actions): DispatchProps => pick(actions, [

View File

@ -231,14 +231,14 @@ export default memo(withGlobal<OwnProps>(
chatsById, chatsById,
usersById, usersById,
lastSyncTime, lastSyncTime,
notifySettings: selectNotifySettings(global),
notifyExceptions: selectNotifyExceptions(global),
...(listType ? { ...(listType ? {
listIds: listIds[listType], listIds: listIds[listType],
orderedPinnedIds: orderedPinnedIds[listType], orderedPinnedIds: orderedPinnedIds[listType],
} : { } : {
chatFolder, chatFolder,
}), }),
notifySettings: selectNotifySettings(global),
notifyExceptions: selectNotifyExceptions(global),
}; };
}, },
(setGlobal, actions): DispatchProps => pick(actions, [ (setGlobal, actions): DispatchProps => pick(actions, [

View File

@ -137,8 +137,8 @@ export default memo(withGlobal<OwnProps>(
return { return {
chat, chat,
...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }),
lastSyncTime: global.lastSyncTime, lastSyncTime: global.lastSyncTime,
...(privateChatUserId && { privateChatUser: selectUser(global, privateChatUserId) }),
}; };
}, },
(setGlobal, actions): DispatchProps => pick(actions, [ (setGlobal, actions): DispatchProps => pick(actions, [

View File

@ -534,12 +534,12 @@ export default memo(withGlobal<OwnProps>(
focusingId, focusingId,
hasFocusHighlight, hasFocusHighlight,
isSelectModeActive: selectIsInSelectMode(global), isSelectModeActive: selectIsInSelectMode(global),
...(withLastMessageWhenPreloading && { lastMessage }),
botDescription, botDescription,
threadTopMessageId, threadTopMessageId,
hasLinkedChat: chat.fullInfo && ('linkedChatId' in chat.fullInfo) hasLinkedChat: chat.fullInfo && ('linkedChatId' in chat.fullInfo)
? Boolean(chat.fullInfo.linkedChatId) ? Boolean(chat.fullInfo.linkedChatId)
: undefined, : undefined,
...(withLastMessageWhenPreloading && { lastMessage }),
}; };
}, },
(setGlobal, actions): DispatchProps => pick(actions, [ (setGlobal, actions): DispatchProps => pick(actions, [

View File

@ -968,10 +968,7 @@ export default memo(withGlobal<OwnProps>(
isThreadTop, isThreadTop,
replyMessage, replyMessage,
replyMessageSender, replyMessageSender,
...(isOutgoing && { outgoingStatus: selectOutgoingStatus(global, message, messageListType === 'scheduled') }),
...(typeof uploadProgress === 'number' && { uploadProgress }),
isFocused, isFocused,
...(isFocused && { focusDirection, noFocusHighlight }),
isForwarding, isForwarding,
isChatWithSelf, isChatWithSelf,
isChannel, isChannel,
@ -989,6 +986,9 @@ export default memo(withGlobal<OwnProps>(
shouldAutoLoadMedia: chat ? selectShouldAutoLoadMedia(global, message, chat, sender) : undefined, shouldAutoLoadMedia: chat ? selectShouldAutoLoadMedia(global, message, chat, sender) : undefined,
shouldAutoPlayMedia: selectShouldAutoPlayMedia(global, message), shouldAutoPlayMedia: selectShouldAutoPlayMedia(global, message),
shouldLoopStickers: selectShouldLoopStickers(global), shouldLoopStickers: selectShouldLoopStickers(global),
...(isOutgoing && { outgoingStatus: selectOutgoingStatus(global, message, messageListType === 'scheduled') }),
...(typeof uploadProgress === 'number' && { uploadProgress }),
...(isFocused && { focusDirection, noFocusHighlight }),
}; };
}, },
(setGlobal, actions): DispatchProps => pick(actions, [ (setGlobal, actions): DispatchProps => pick(actions, [

View File

@ -459,15 +459,15 @@ export default memo(withGlobal<OwnProps>(
areMembersHidden, areMembersHidden,
canAddMembers, canAddMembers,
canDeleteMembers, canDeleteMembers,
...(hasMembersTab && members && {
members,
usersById,
}),
currentUserId: global.currentUserId, currentUserId: global.currentUserId,
isRightColumnShown: selectIsRightColumnShown(global), isRightColumnShown: selectIsRightColumnShown(global),
isRestricted: chat && chat.isRestricted, isRestricted: chat && chat.isRestricted,
lastSyncTime: global.lastSyncTime, lastSyncTime: global.lastSyncTime,
serverTimeOffset: global.serverTimeOffset, serverTimeOffset: global.serverTimeOffset,
...(hasMembersTab && members && {
members,
usersById,
}),
}; };
}, },
(setGlobal, actions): DispatchProps => pick(actions, [ (setGlobal, actions): DispatchProps => pick(actions, [