-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add delegate avatar component #48564
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import Avatar from '@components/Avatar'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils'; | ||
import * as UserUtils from '@libs/UserUtils'; | ||
import CONST from '@src/CONST'; | ||
import ProfileAvatarWithIndicator from './ProfileAvatarWithIndicator'; | ||
|
||
type AvatarWithDelegateAvatarProps = { | ||
/** Emoji status */ | ||
delegateEmail: string; | ||
|
||
/** Whether the avatar is selected */ | ||
isSelected?: boolean; | ||
}; | ||
|
||
function AvatarWithDelegateAvatar({delegateEmail, isSelected = false}: AvatarWithDelegateAvatarProps) { | ||
const styles = useThemeStyles(); | ||
const personalDetail = PersonalDetailsUtils.getPersonalDetailByEmail(delegateEmail); | ||
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. perhaps put this one under useCallback or something which will trigger a re-render 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.
@dangrous
Is not working as expected for the first load 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. Oh i get it, we are calling the wrong util, that util gives us the cache, when we switch account there is none @DylanDylann can you update the util please 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. oh nice find. Alternately, is there a way we can preserve the personal details of the delegate account in the cache when we switch accounts (and past reload)? Trying to avoid unnecessary calls to the backend if we already have that info 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. We have to use useOnyx. Otherwise the variable won't update when underlying data changes |
||
|
||
return ( | ||
<View style={styles.sidebarStatusAvatarContainer}> | ||
<ProfileAvatarWithIndicator isSelected={isSelected} /> | ||
<View style={[styles.sidebarStatusAvatar]}> | ||
<View style={styles.emojiStatusLHN}> | ||
<Avatar | ||
size={CONST.AVATAR_SIZE.SMALL} | ||
source={UserUtils.getSmallSizeAvatar(personalDetail?.avatar, personalDetail?.accountID)} | ||
fallbackIcon={personalDetail?.fallbackIcon} | ||
type={CONST.ICON_TYPE_AVATAR} | ||
/> | ||
</View> | ||
</View> | ||
</View> | ||
); | ||
} | ||
|
||
AvatarWithDelegateAvatar.displayName = 'AvatarWithDelegateAvatar'; | ||
|
||
export default AvatarWithDelegateAvatar; |
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.
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.
@DylanDylann is off for the night, i guess you can force push this commit @dangrous ? lets get the ball rolling imo
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 think I won't be able to merge if I do that unfortunately, a little wonky but @allgandalf can you add it into your PR? I'll go ahead and merge this as is.
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.
yes sure!