Skip to content

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

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

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.

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

3 participants