Skip to content
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

Avatar adding new users #22693

Merged
merged 5 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/components/MultipleAvatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ function MultipleAvatars(props) {
<UserDetailsTooltip
accountID={props.icons[0].id}
icon={props.icons[0]}
fallbackUserDetails={{
displayName: props.icons[0].name,
avatar: props.icons[0].avatar,
}}
>
<View style={avatarContainerStyles}>
<Avatar
Expand Down Expand Up @@ -158,6 +162,10 @@ function MultipleAvatars(props) {
key={`stackedAvatars-${index}`}
accountID={icon.id}
icon={icon}
fallbackUserDetails={{
displayName: icon.name,
avatar: icon.avatar,
}}
>
<View
style={[
Expand Down Expand Up @@ -226,6 +234,10 @@ function MultipleAvatars(props) {
<UserDetailsTooltip
accountID={props.icons[0].id}
icon={props.icons[0]}
fallbackUserDetails={{
displayName: props.icons[0].name,
avatar: props.icons[0].avatar,
}}
>
{/* View is necessary for tooltip to show for multiple avatars in LHN */}
<View>
Expand All @@ -244,6 +256,10 @@ function MultipleAvatars(props) {
<UserDetailsTooltip
accountID={props.icons[1].id}
icon={props.icons[1]}
fallbackUserDetails={{
displayName: props.icons[1].name,
avatar: props.icons[1].avatar,
}}
>
<View>
<Avatar
Expand Down
11 changes: 9 additions & 2 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,18 @@ function addSMSDomainIfPhoneNumber(login) {
*
* @param {Array<Number>} accountIDs
* @param {Object} personalDetails
* @param {Object} defaultValues {login: accountID} In workspace invite page, when new user is added we pass available data to opt in
* @returns {Object}
*/
function getAvatarsForAccountIDs(accountIDs, personalDetails) {
function getAvatarsForAccountIDs(accountIDs, personalDetails, defaultValues = {}) {
const reversedDefaultValues = {};
_.map(Object.entries(defaultValues), (item) => {
reversedDefaultValues[item[1]] = item[0];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly confused - item is a two-value array? Where item[0] is a login and item[1] is an accountID?

This seems very specific to workspace stuff where we use "emailsToAccountIDs" stuff... Even the function comment agrees it's only for workspace stuff... I feel like this would have been better as a separate function or something 🤷 this all looks terribly confusing for the standard use-case 😅

@mountiny sorry to jump in to a PR you reviewed, do you agree or disagree with my annoying thoughts? 😅

});

return _.map(accountIDs, (accountID) => {
const userPersonalDetail = lodashGet(personalDetails, accountID, {login: '', accountID, avatar: ''});
const login = lodashGet(reversedDefaultValues, accountID, '');
const userPersonalDetail = lodashGet(personalDetails, accountID, {login, accountID, avatar: ''});
return {
id: accountID,
source: UserUtils.getAvatar(userPersonalDetail.avatar, userPersonalDetail.accountID),
Expand Down
6 changes: 5 additions & 1 deletion src/pages/workspace/WorkspaceInviteMessagePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ class WorkspaceInviteMessagePage extends React.Component {
<View style={[styles.mv4, styles.justifyContentCenter, styles.alignItemsCenter]}>
<MultipleAvatars
size={CONST.AVATAR_SIZE.LARGE}
icons={OptionsListUtils.getAvatarsForAccountIDs(_.values(this.props.invitedEmailsToAccountIDsDraft), this.props.personalDetails)}
icons={OptionsListUtils.getAvatarsForAccountIDs(
_.values(this.props.invitedEmailsToAccountIDsDraft),
this.props.personalDetails,
this.props.invitedEmailsToAccountIDsDraft,
)}
shouldStackHorizontally
shouldDisplayAvatarsInRows
secondAvatarStyle={[styles.secondAvatarInline]}
Expand Down