From 175b400b6da35189728a3a42aded2b8bc14b1c9e Mon Sep 17 00:00:00 2001 From: Georgia Monahan Date: Wed, 18 Sep 2024 13:57:03 +0100 Subject: [PATCH] useMemo for the helper functions --- .../home/report/ReportActionItemSingle.tsx | 201 ++++++++++-------- 1 file changed, 114 insertions(+), 87 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.tsx b/src/pages/home/report/ReportActionItemSingle.tsx index 8dcbcd180273..1128bbb781b6 100644 --- a/src/pages/home/report/ReportActionItemSingle.tsx +++ b/src/pages/home/report/ReportActionItemSingle.tsx @@ -200,99 +200,126 @@ function ReportActionItemSingle({ [action, isWorkspaceActor, actorAccountID], ); - const getAvatar = () => { - if (displayAllActors) { - return ( - - ); - } - if (shouldShowSubscriptAvatar) { + const getAvatar = useMemo(() => { + return () => { + if (displayAllActors) { + return ( + + ); + } + if (shouldShowSubscriptAvatar) { + return ( + + ); + } return ( - + + + + + ); - } - return ( - - - - - - ); - }; + }; + }, [ + displayAllActors, + shouldShowSubscriptAvatar, + actorAccountID, + action?.delegateAccountID, + icon, + styles.actionAvatar, + fallbackIcon, + secondaryAvatar, + StyleUtils, + theme.appBG, + theme.hoverComponentBG, + isHovered, + ]); - const getHeading = () => { - if (displayAllActors && secondaryAvatar.name) { + const getHeading = useMemo(() => { + return () => { + if (displayAllActors && secondaryAvatar.name && isReportPreviewAction) { + return ( + + + + {` & `} + + + + ); + } return ( - - - - {` & `} - - + + {personArray?.map((fragment) => ( + + ))} ); - } - return ( - - {personArray?.map((fragment, index) => ( - - ))} - - ); - }; + }; + }, [ + displayAllActors, + secondaryAvatar, + isReportPreviewAction, + personArray, + styles.flexRow, + styles.flex1, + styles.chatItemMessageHeaderSender, + styles.pre, + action, + actorAccountID, + displayName, + icon, + ]); const hasEmojiStatus = !displayAllActors && status?.emojiCode; const formattedDate = DateUtils.getStatusUntilDate(status?.clearAfter ?? '');