-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Command Palette: Use getRevisions instead of deprecated selector #56738
Conversation
Size Change: +686 B (0%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
const globalStylesRevisions = getRevisions( | ||
'root', | ||
'globalStyles', | ||
__experimentalGetCurrentGlobalStylesId() | ||
); | ||
return !! globalStylesRevisions?.length; |
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.
Thanks for picking this up @t-hamano 🙇🏻
Because the revisions response could be larger (at the moment up to 100 items in the collection), maybe it would be faster to grab the revision count from the version-history
meta?
E.g.,
const globalStylesId = __experimentalGetCurrentGlobalStylesId();
const globalStyles = globalStylesId
? getEntityRecord( 'root', 'globalStyles', globalStylesId )
: undefined;
return globalStyles?._links?.[ 'version-history' ]?.[ 0 ]?.count || 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.
+1, thanks for working on this!
That would be good if it's possible to use version-history
and avoid the extra API call 👍
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.
Indeed. I updated it with 2257407 and confirmed that it continues to work as expected 👍
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.
🚢
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.
LGTM, too, and confirmed the revisions
endpoint for global styles is only called after going to the revisions screen. ✨
Related to #56349
What?
This PR refactors the deprecated
getCurrentThemeGlobalStylesRevisions
selector into thegetRevisions
selector in the Command Palette. This will prevent warning messages from appearing in the browser console.Why?
To improve code quality.
How?
Refactored it while keeping the logic. However, I added
!!
to explicitly return aboolean
type.Testing Instructions
Screenshots or screencast
2c76837f063b5b2ebb45e23b0abefe29.mp4