Skip to content

Commit

Permalink
Editor: Optimize global styles permission check (#65177)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: youknowriad <[email protected]>
  • Loading branch information
3 people authored Sep 10, 2024
1 parent 1c44c41 commit 1cc30c5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/editor/src/components/global-styles-provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ function useGlobalStylesUserConfig() {

function useGlobalStylesBaseConfig() {
const baseConfig = useSelect( ( select ) => {
const { __experimentalGetCurrentThemeBaseGlobalStyles, canUser } =
select( coreStore );

return (
canUser( 'read', { kind: 'root', name: 'theme' } ) &&
__experimentalGetCurrentThemeBaseGlobalStyles()
);
const {
__experimentalGetCurrentThemeBaseGlobalStyles,
getCurrentTheme,
canUser,
} = select( coreStore );
const currentTheme = getCurrentTheme();

return currentTheme &&
canUser( 'read', 'global-styles/themes', currentTheme.stylesheet )
? __experimentalGetCurrentThemeBaseGlobalStyles()
: undefined;
}, [] );

return [ !! baseConfig, baseConfig ];
Expand Down

0 comments on commit 1cc30c5

Please sign in to comment.