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

Fixed changing a user photo in the header #2812

Merged
merged 5 commits into from
Nov 22, 2024
Merged
Changes from 3 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
19 changes: 15 additions & 4 deletions src/containers/navigation-icons/AccountIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ const AccountIcon: FC<AccountIconProps> = ({ openMenu }) => {
defaultResponse: defaultResponses.object as UserResponse
})

const { photo: statePhoto } = useAppSelector((state) => state.editProfile)

const getAvatarSrc = useCallback(() => {
if (statePhoto && statePhoto.src) {
Made1ra marked this conversation as resolved.
Show resolved Hide resolved
return statePhoto.src
}

if (photo) {
return createUrlPath(import.meta.env.VITE_APP_IMG_USER_URL || '', photo)
}
}, [photo, statePhoto])

const avatarSrc = getAvatarSrc()

if (loading) {
return <Avatar sx={styles.accountIcon} />
}
Expand All @@ -46,10 +60,7 @@ const AccountIcon: FC<AccountIconProps> = ({ openMenu }) => {
<Avatar
alt='User Avatar'
onClick={openMenu}
src={
photo &&
createUrlPath(import.meta.env.VITE_APP_IMG_USER_URL || '', photo)
}
src={avatarSrc}
sx={styles.accountIcon}
>
{!loading && firstName && lastName && `${firstName[0]}${lastName[0]}`}
Expand Down
Loading