-
Notifications
You must be signed in to change notification settings - Fork 3k
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
DMs to show all avatars #21402
DMs to show all avatars #21402
Conversation
Signed-off-by: wikuskriek <[email protected]>
Signed-off-by: wikuskriek <[email protected]>
@mananjadhav would appreciate you just scanning this over and giving some feedback. |
Signed-off-by: wikuskriek <[email protected]>
Signed-off-by: wikuskriek <[email protected]>
@shawnborton @mananjadhav One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Nice, this looks good to me. Should we also update the invite to workspace flow where we show avatars as well? cc @puneetlath for review too |
I only looked at the videos, not the code, but it looks good to me too! |
On that page it can be a theoretically infinite number of users right? Whereas on the group chat page it's max 8. If so, I think it's fine to leave the invite page as-is. Or were you think we'd use the same pattern with up to 8? |
It will look something like this, might need to also just dynamically change avatar size. Some change will be needed for the +(more users) text logic. It currently overflows on both rows. Screen.Recording.2023-06-24.at.08.37.16.mov |
That does look pretty nice. |
The screencasts look good, I am currently reviewing the code. |
Nice, I like that as well! |
Let's do it then @WikusKriek. And we can double the bounty for the scope increase. |
@mananjadhav I have pushed more changes now related to workflow invite avatars. |
@@ -191,6 +191,7 @@ class WorkspaceInviteMessagePage extends React.Component { | |||
size={CONST.AVATAR_SIZE.LARGE} | |||
icons={OptionsListUtils.getAvatarsForAccountIDs(_.values(this.props.invitedEmailsToAccountIDsDraft), this.props.personalDetails)} | |||
shouldStackHorizontally | |||
shouldStackVertically |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having both shouldStackHorizontally
and shouldStackVertically
sound confusing. Can we rename them better based on their use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will leave shouldStackHorizontally as is and rename shlouldStackVertically to shouldDisplayAvatarsInRows.
src/components/MultipleAvatars.js
Outdated
@@ -57,20 +63,34 @@ const defaultProps = { | |||
secondAvatarStyle: [StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)], | |||
fallbackIcon: undefined, | |||
shouldStackHorizontally: false, | |||
shouldStackVertically: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should one of them be true by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it is not a case of the one or the other. There is a case where both are false and it executes thie code
App/src/components/MultipleAvatars.js
Lines 185 to 228 in e5f00f8
<View style={singleAvatarStyles}> | |
<UserDetailsTooltip accountID={props.icons[0].id}> | |
{/* View is necessary for tooltip to show for multiple avatars in LHN */} | |
<View> | |
<Avatar | |
source={props.icons[0].source || props.fallbackIcon} | |
fill={themeColors.iconSuccessFill} | |
size={props.isFocusMode ? CONST.AVATAR_SIZE.MID_SUBSCRIPT : CONST.AVATAR_SIZE.SMALLER} | |
imageStyles={[singleAvatarStyles]} | |
name={props.icons[0].name} | |
type={props.icons[0].type} | |
/> | |
</View> | |
</UserDetailsTooltip> | |
<View style={secondAvatarStyles}> | |
{props.icons.length === 2 ? ( | |
<UserDetailsTooltip accountID={props.icons[1].id}> | |
<View> | |
<Avatar | |
source={props.icons[1].source || props.fallbackIcon} | |
fill={themeColors.iconSuccessFill} | |
size={props.isFocusMode ? CONST.AVATAR_SIZE.MID_SUBSCRIPT : CONST.AVATAR_SIZE.SMALLER} | |
imageStyles={[singleAvatarStyles]} | |
name={props.icons[1].name} | |
type={props.icons[1].type} | |
/> | |
</View> | |
</UserDetailsTooltip> | |
) : ( | |
<Tooltip text={tooltipTexts.slice(1).join(', ')}> | |
<View style={[singleAvatarStyles, styles.alignItemsCenter, styles.justifyContentCenter]}> | |
<Text | |
selectable={false} | |
style={props.size === CONST.AVATAR_SIZE.SMALL ? styles.avatarInnerTextSmall : styles.avatarInnerText} | |
> | |
{`+${props.icons.length - 1}`} | |
</Text> | |
</View> | |
</Tooltip> | |
)} | |
</View> | |
</View> | |
)} | |
</View> |
src/components/MultipleAvatars.js
Outdated
let avatarContainerStyles = props.size === CONST.AVATAR_SIZE.SMALL ? [styles.emptyAvatarSmall, styles.emptyAvatarMarginSmall] : [styles.emptyAvatar, styles.emptyAvatarMargin]; | ||
const singleAvatarStyles = props.size === CONST.AVATAR_SIZE.SMALL ? styles.singleAvatarSmall : styles.singleAvatar; | ||
const secondAvatarStyles = [props.size === CONST.AVATAR_SIZE.SMALL ? styles.secondAvatarSmall : styles.secondAvatar, ...props.secondAvatarStyle]; | ||
const tooltipTexts = props.shouldShowTooltip ? _.pluck(props.icons, 'name') : ['']; | ||
|
||
useEffect(() => { | ||
if (props.shouldStackVertically && props.icons.length > props.maxAvatars) { | ||
const rowSize = Math.min(Math.ceil(props.icons.length / 2), props.maxAvatars); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this block to another method? and have some comments there?
@mananjadhav It should look like this, I missed a change but pushed the fix now. |
Thanks for the fix @WikusKriek. Testing again now. |
Reviewer Checklist
Screenshots/VideosDesktopdesktop-multile-avatars.mov@WikusKriek this tests well, just one thing is missing, can you upload screencasts for the workspace invite image? 🎀 👀 🎀 C+ Reviewed. @shawnborton @puneetlath all yours. |
@mananjadhav I added screen recordings of workspace invite. |
Thanks @WikusKriek. @puneetlath @shawnborton if you folks can take a look. |
I think this feels good to me. |
src/components/MultipleAvatars.js
Outdated
setAvatarRows([firstRow, secondRow]); | ||
}; | ||
|
||
// useEffect hook to update avatar rows when props change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAB: I don't think this comment is necessary. The code right below it pretty clearly does exactly what this comment says.
@WikusKriek FYI you have conflicts. @roryabraham do you want to approve as well? You're technically the CME on the issue. |
Looks like Rory is OOO, so I'm going to go ahead and merge. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/puneetlath in version: 1.3.38-0 🚀
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.3.38-7 🚀
|
> | ||
{`+${props.icons.length - 1}`} | ||
</Text> | ||
<Text style={[styles.avatarInnerTextSmall, StyleUtils.getAvatarExtraFontSizeStyle(props.size)]}>{`+${avatars.length - props.maxAvatarsInRow}`}</Text> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{avatars.length > props.maxAvatarsInRow && ( | ||
<Tooltip | ||
// We only want to cap tooltips to only the first 10 users or so since some reports have hundreds of users, causing performance to degrade. | ||
text={tooltipTexts.slice(3, 10).join(', ')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was missed to change tooltip text while implementing this feature so it caused regression - #22951
More details:
Bug: #22951 (comment)
Root cause: #22951 (comment)
useEffect(() => { | ||
calculateAvatarRows(); | ||
|
||
// The only dependencies of the effect are based on props, so we can safely disable the exhaustive-deps rule | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [props.icons, props.maxAvatarsInRow, props.shouldDisplayAvatarsInRows]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greetings,
This code has introduced a regression in #24062. The useEffect
is triggered after the re-rendering process, during which the app uses outdated state data along with the new prop data, leading to a crash. Rather than using useEffect
in combination with State, the recommended approach involves using useMemo
to recalculate the data upon prop changes. This adjustment guarantees the correct flow of data.
|
||
// Slice the icons array into two rows | ||
const firstRow = props.icons.slice(rowSize); | ||
const secondRow = props.icons.slice(0, rowSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Coming from #31151
The slice seems backward between firstRow
and secondRow
, so causing the issue.
Details
Feature request to show up to 8 person Avatars in DMs.
Fixed Issues
$ #15929 (comment)
PROPOSAL: #15929 (comment)
Tests
Offline tests
N/A
QA Steps
Same as Test Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
Web.Chrome.2023-07-04.at.18.07.43.mov
MacOS.Chrome.2023-06-23.at.17.01.14.mov
Mobile Web - Chrome
Android.Chrome.2023-07-04.at.18.55.37.mov
Android.Native.2023-06-23.at.17.30.34.mov
Mobile Web - Safari
IOS.Safari.2023-07-04.at.18.39.15.mov
IOS.Safari.2023-06-23.at.19.00.39.mov
Desktop
Desktop.2023-07-04.at.19.18.00.mov
MacOS.Desktop.2023-06-23.at.19.05.18.mov
iOS
IOS.Native.2023-07-04.at.18.34.36.mov
IOS.Native.2023-06-23.at.18.58.01.mov
Android
Android.Native.2023-07-04.at.18.50.22.mov
Android.Native.2023-06-23.at.17.30.34.mov