-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[ReportPreview / Text] When showing two avatars, also show both display names with tooltip #50341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,24 +150,40 @@ function ReportActionItemSingle({ | |
} else { | ||
secondaryAvatar = {name: '', source: '', type: 'avatar'}; | ||
} | ||
const icon = { | ||
source: avatarSource ?? FallbackAvatar, | ||
type: isWorkspaceActor ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR, | ||
name: primaryDisplayName ?? '', | ||
id: avatarId, | ||
}; | ||
const icon = useMemo( | ||
() => ({ | ||
source: avatarSource ?? FallbackAvatar, | ||
type: isWorkspaceActor ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR, | ||
name: primaryDisplayName ?? '', | ||
id: avatarId, | ||
}), | ||
[avatarSource, isWorkspaceActor, primaryDisplayName, avatarId], | ||
); | ||
|
||
// Since the display name for a report action message is delivered with the report history as an array of fragments | ||
// we'll need to take the displayName from personal details and have it be in the same format for now. Eventually, | ||
// we should stop referring to the report history items entirely for this information. | ||
const personArray = displayName | ||
? [ | ||
{ | ||
type: 'TEXT', | ||
text: displayName, | ||
}, | ||
] | ||
: action?.person; | ||
const personArray = useMemo(() => { | ||
const baseArray = displayName | ||
? [ | ||
{ | ||
type: 'TEXT', | ||
text: displayName, | ||
}, | ||
] | ||
: [action?.person?.at(0)] ?? []; | ||
|
||
if (displayAllActors && secondaryAvatar?.name) { | ||
return [ | ||
...baseArray, | ||
{ | ||
type: 'TEXT', | ||
text: secondaryAvatar?.name ?? '', | ||
}, | ||
]; | ||
} | ||
return baseArray; | ||
}, [displayName, action?.person, displayAllActors, secondaryAvatar?.name]); | ||
|
||
const reportID = report?.reportID; | ||
const iouReportID = iouReport?.reportID; | ||
|
@@ -231,6 +247,73 @@ function ReportActionItemSingle({ | |
</UserDetailsTooltip> | ||
); | ||
}; | ||
|
||
const getHeading = useMemo(() => { | ||
return () => { | ||
if (displayAllActors && personArray.length === 2 && isReportPreviewAction) { | ||
return ( | ||
<View style={[styles.flexRow]}> | ||
<ReportActionItemFragment | ||
style={[styles.flex1]} | ||
key={`person-${action?.reportActionID}-${0}`} | ||
accountID={actorAccountID ?? -1} | ||
fragment={{...personArray.at(0), type: 'TEXT', text: displayName ?? ''}} | ||
delegateAccountID={action?.delegateAccountID} | ||
isSingleLine | ||
actorIcon={icon} | ||
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision} | ||
/> | ||
<Text | ||
numberOfLines={1} | ||
style={[styles.chatItemMessageHeaderSender, styles.pre]} | ||
> | ||
{` & `} | ||
</Text> | ||
<ReportActionItemFragment | ||
style={[styles.flex1]} | ||
key={`person-${action?.reportActionID}-${1}`} | ||
accountID={parseInt(`${secondaryAvatar?.id ?? -1}`, 10)} | ||
fragment={{...personArray.at(1), type: 'TEXT', text: secondaryAvatar.name ?? ''}} | ||
delegateAccountID={action?.delegateAccountID} | ||
isSingleLine | ||
actorIcon={secondaryAvatar} | ||
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision} | ||
/> | ||
</View> | ||
); | ||
} | ||
return ( | ||
<View> | ||
{personArray.map((fragment) => ( | ||
<ReportActionItemFragment | ||
style={[styles.flex1]} | ||
key={`person-${action?.reportActionID}-${actorAccountID}`} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to use index suffix like before. Because it's possible that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To clarify the above comment, we may be able to remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. For the lint error, maybe we can just disable the lint by adding
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I see what you mean, updating now. |
||
accountID={actorAccountID ?? -1} | ||
fragment={{...fragment, type: fragment?.type ?? '', text: fragment?.text ?? ''}} | ||
delegateAccountID={action?.delegateAccountID} | ||
isSingleLine | ||
actorIcon={icon} | ||
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision} | ||
/> | ||
))} | ||
</View> | ||
); | ||
}; | ||
}, [ | ||
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 ?? ''); | ||
const statusText = status?.text ?? ''; | ||
|
@@ -261,18 +344,7 @@ function ReportActionItemSingle({ | |
accessibilityLabel={actorHint} | ||
role={CONST.ROLE.BUTTON} | ||
> | ||
{personArray?.map((fragment, index) => ( | ||
<ReportActionItemFragment | ||
// eslint-disable-next-line react/no-array-index-key | ||
key={`person-${action?.reportActionID}-${index}`} | ||
accountID={actorAccountID ?? -1} | ||
fragment={{...fragment, type: fragment.type ?? '', text: fragment.text ?? ''}} | ||
delegateAccountID={action?.delegateAccountID} | ||
isSingleLine | ||
actorIcon={icon} | ||
moderationDecision={getReportActionMessage(action)?.moderationDecision?.decision} | ||
/> | ||
))} | ||
{getHeading()} | ||
</PressableWithoutFeedback> | ||
{!!hasEmojiStatus && ( | ||
<Tooltip text={statusTooltipText}> | ||
|
Uh oh!
There was an error while loading. Please reload this page.