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

Fix conditional name in avatar #102

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/components/UserPopup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const UserPopup = (props: UserPopupProps) => {
<ScopedCssBaseline>
<UserPopUp>
<UserPopUpContainer>
<StyledAvatar alt={user.name[0] ?? user.username?.charAt(0)}>
<StyledAvatar alt={user.name[0] ?? user.username?.charAt(0) ?? '-'}>
Copy link
Member

Choose a reason for hiding this comment

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

This line continues to throw an error if user or user.name is null or undefined.

{(user.name[0] ?? user.username?.charAt(0)) ?? ''}
</StyledAvatar>
<UserName>{user.name ?? user.username ?? 'User Display Name'}</UserName>
Expand Down
4 changes: 2 additions & 2 deletions src/lib-components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const Navbar = ({
onClick={handleUserMenu}
color='inherit'
>
<Avatar sx={{ bgcolor: '#db1e2f' }} alt={profile.name[0]}>
<Avatar sx={{ bgcolor: '#db1e2f' }} alt={profile.name[0] ?? '-'}>
Copy link
Member

Choose a reason for hiding this comment

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

The same thing here. If profile.name is null or undefined this code will throw an error.

{profile.name[0]?.charAt(0) ?? profile.username?.charAt(0) ?? ''}
</Avatar>
</IconButton>
Expand Down Expand Up @@ -307,7 +307,7 @@ export const Navbar = ({
onClick={handleUserMenu}
color='inherit'
>
<Avatar sx={{ bgcolor: '#db1e2f' }} alt={profile.name[0]}>
<Avatar sx={{ bgcolor: '#db1e2f' }} alt={profile.name[0] ?? '-'}>
Copy link
Member

Choose a reason for hiding this comment

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

Same

{profile.name[0].charAt(0)}
</Avatar>
</IconButton>
Expand Down