From c672c59ecb3bfcb1564fa4366ef7310b80d9136a Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Mon, 20 Nov 2023 11:51:00 +0100 Subject: [PATCH] remove withOnyx from tooltip & implement in OptionRow --- src/components/MultipleAvatars.tsx | 22 ++++++++++++++----- src/components/OptionRow.js | 1 + .../BaseUserDetailsTooltip.web.js | 6 ++--- .../userDetailsTooltipPropTypes.js | 9 ++++---- 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/components/MultipleAvatars.tsx b/src/components/MultipleAvatars.tsx index febe18f30c7d..0283d87fd6ef 100644 --- a/src/components/MultipleAvatars.tsx +++ b/src/components/MultipleAvatars.tsx @@ -11,6 +11,7 @@ import type {Icon} from '@src/types/onyx/OnyxCommon'; import Avatar from './Avatar'; import Text from './Text'; import Tooltip from './Tooltip'; +import participantPropTypes from './participantPropTypes'; import UserDetailsTooltip from './UserDetailsTooltip'; type MultipleAvatarsProps = { @@ -52,6 +53,9 @@ type MultipleAvatarsProps = { /** Prop to limit the amount of avatars displayed horizontally */ maxAvatarsInRow?: number; + + /** List of participants */ + participants: PropTypes.arrayOf(participantPropTypes) }; type AvatarStyles = { @@ -92,6 +96,7 @@ function MultipleAvatars({ shouldShowTooltip = true, shouldUseCardBackground = false, maxAvatarsInRow = CONST.AVATAR_ROW_SIZE.DEFAULT, + participants = [], }: MultipleAvatarsProps) { let avatarContainerStyles = StyleUtils.getContainerStyles(size, isInReportAction); const {singleAvatarStyle, secondAvatarStyles} = useMemo(() => avatarSizeToStylesMap[size as AvatarSizeToStyles] ?? avatarSizeToStylesMap.default, [size]); @@ -109,6 +114,13 @@ function MultipleAvatars({ return CONST.AVATAR_SIZE.SMALLER; }, [isFocusMode, size]); + const participantsList = useMemo(() => _.reduce(participants, (all, participant) => { + // eslint-disable-next-line no-param-reassign + all[participant.accountID] = participant; + + return all; + }, {}), [participants]) + const avatarRows = useMemo(() => { // If we're not displaying avatars in rows or the number of icons is less than or equal to the max avatars in a row, return a single row if (!shouldDisplayAvatarsInRows || icons.length <= maxAvatarsInRow) { @@ -133,7 +145,7 @@ function MultipleAvatars({ if (icons.length === 1 && !shouldStackHorizontally) { return ( {[...avatars].splice(0, maxAvatarsInRow).map((icon, index) => ( {icons.length === 2 ? ( ) : (