-
Notifications
You must be signed in to change notification settings - Fork 4.7k
PostFeaturedImage: Remove unnecessary 'block-editor' store subscription #57554
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
Conversation
| mediaUpload( { | ||
| allowedTypes: [ 'image' ], | ||
| getSettings().mediaUpload( { | ||
| allowedTypes: ALLOWED_MEDIA_TYPES, |
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.
I'm just re-using the existing constant here.
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.
Nice 👍
|
Size Change: +2 B (0%) Total Size: 1.69 MB
ℹ️ View Unchanged
|
tyxla
left a comment
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.
Tests well and the code LGTM. 🚀
From what I understand, the performance impact is unmeasurable and purely theoretical, since this removes just a single out of thousands of subscriptions, but it's still a good improvement.
Thanks @Mamaduka! 🙌
| mediaUpload( { | ||
| allowedTypes: [ 'image' ], | ||
| getSettings().mediaUpload( { | ||
| allowedTypes: ALLOWED_MEDIA_TYPES, |
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.
Nice 👍
|
Thank you, @tyxla! You're right. This is mostly micro-optimization. It doesn't have a noticeable impact, but practices from the core are often adopted by third parties, so we should try our best 😄 |
What?
This is similar to #57513.
PR removes an unnecessary 'block-editor' store subscription from the
PostFeaturedImagecomponent.Why?
The media
mediaUploadsetting is only used during theonDropFilesevent. We can use a static selector getter and grab the setting only when needed. It's a good practice to avoid store subscriptions when unnecessary.Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast
CleanShot.2024-01-04.at.20.59.41.mp4