-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40090 from kubabutkiewicz/ts-migration/ProfileAva…
…tarWithIndicator [TS migration] Migrate ProfileAvatarWithIndicator.js component to TypeScript
- Loading branch information
Showing
3 changed files
with
39 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import AvatarWithIndicator from '@components/AvatarWithIndicator'; | ||
import OfflineWithFeedback from '@components/OfflineWithFeedback'; | ||
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as UserUtils from '@libs/UserUtils'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
||
type ProfileAvatarWithIndicatorProps = { | ||
/** Whether the avatar is selected */ | ||
isSelected?: boolean; | ||
}; | ||
|
||
function ProfileAvatarWithIndicator({isSelected = false}: ProfileAvatarWithIndicatorProps) { | ||
const styles = useThemeStyles(); | ||
const currentUserPersonalDetails = useCurrentUserPersonalDetails(); | ||
const [isLoadingOnyxValue] = useOnyx(ONYXKEYS.IS_LOADING_APP); | ||
const isLoading = isLoadingOnyxValue ?? true; | ||
|
||
return ( | ||
<OfflineWithFeedback pendingAction={currentUserPersonalDetails.pendingFields?.avatar}> | ||
<View style={[isSelected && styles.selectedAvatarBorder]}> | ||
<AvatarWithIndicator | ||
source={UserUtils.getAvatar(currentUserPersonalDetails.avatar, currentUserPersonalDetails.accountID)} | ||
fallbackIcon={currentUserPersonalDetails.fallbackIcon} | ||
isLoading={isLoading && !currentUserPersonalDetails.avatar} | ||
/> | ||
</View> | ||
</OfflineWithFeedback> | ||
); | ||
} | ||
|
||
ProfileAvatarWithIndicator.displayName = 'ProfileAvatarWithIndicator'; | ||
|
||
export default ProfileAvatarWithIndicator; |