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

Block Library (Avatar Block): Remove Unnecessary '&& check' as 'optional chaining (authorDetails?.avatar_urls) check' is already used #41779

Merged
merged 1 commit into from
Jun 18, 2022

Conversation

hz-tyfoon
Copy link
Contributor

@hz-tyfoon hz-tyfoon commented Jun 17, 2022

Hey Everyone, This is my first PR. Please review it. 🙂

What?

In line number 81 & 85, There's && check for authorDetails and then optional chaining (?.) is used. Looks like using both of them together is unnecessary.
Just only using authorDetails && authorDetails.avatar_urls without the 'optional chaining (?)' is enough.
Or Just only using the latter check like authorDetails?.avatar_urls is also enough. (I did this one in my PR)

Why?

In the scenario where authorDetails is null or undefined, just using the optional chaining check like this: authorDetails?.avatar_urls will prevent any error and will return 'undefined'. So, in that scenario there won't be any error and also as Conditional (ternary) operator is used for avatarUrls & sizes, both of this will be null (won't cause any error).

@hz-tyfoon hz-tyfoon requested a review from ajitbohra as a code owner June 17, 2022 09:37
@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jun 17, 2022
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @hz-tyfoon! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@Mamaduka Mamaduka requested a review from cbravobernal June 17, 2022 09:48
@cbravobernal cbravobernal added [Block] Avatar Affects the Avatar Block [Type] Code Quality Issues or PRs that relate to code quality labels Jun 17, 2022
Copy link
Contributor

@cbravobernal cbravobernal left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! LGTM! Let's see if we pass the admin e2e tests os we can merge it.

@hz-tyfoon
Copy link
Contributor Author

Thanks for contributing! LGTM! Let's see if we pass the admin e2e tests os we can merge it.

Thanks. 🙂

Copy link
Contributor

@alexstine alexstine left a comment

Choose a reason for hiding this comment

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

Tested and looks good. E2E tests now passing.

@alexstine alexstine merged commit 0b7378a into WordPress:trunk Jun 18, 2022
@github-actions github-actions bot added this to the Gutenberg 13.6 milestone Jun 18, 2022
@hz-tyfoon
Copy link
Contributor Author

Tested and looks good. E2E tests now passing.

Cool. Thanks @alexstine. 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Avatar Affects the Avatar Block First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants