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

Conversation

antoniomarcelob
Copy link

No description provided.

Copy link
Member

@weltonfelix weltonfelix left a 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 "".

@@ -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.

@@ -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.

@@ -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

Copy link
Member

@weltonfelix weltonfelix left a comment

Choose a reason for hiding this comment

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

Changes in review.

@antoniomarcelob antoniomarcelob force-pushed the feature/fix-conditional-name-in-avatar branch from 7750953 to 1887516 Compare April 15, 2024 13:55
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants