-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: develop
Are you sure you want to change the base?
Conversation
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.
The null checks only works if those properties are empty strings.
Also, String.chartAt()
always return a string. I.e. "".charAt(0)
returns ""
, so "" ?? "-"
will always return ""
.
src/components/UserPopup/index.tsx
Outdated
@@ -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) ?? '-'}> |
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.
This line continues to throw an error if user
or user.name
is null or undefined.
src/lib-components/Navbar/index.tsx
Outdated
@@ -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] ?? '-'}> |
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.
The same thing here. If profile.name
is null or undefined this code will throw an error.
src/lib-components/Navbar/index.tsx
Outdated
@@ -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] ?? '-'}> |
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.
Same
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.
Changes in review.
7750953
to
1887516
Compare
|
No description provided.