Skip to content

Commit

Permalink
Editor: Remove resolvers hack for post actions (#64094)
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 committed Jul 30, 2024
1 parent 78a3e71 commit f070092
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,25 +681,17 @@ export const duplicateTemplatePartAction = {
};

export function usePostActions( { postType, onActionPerformed, context } ) {
const {
defaultActions,
postTypeObject,
userCanCreatePostType,
cachedCanUserResolvers,
} = useSelect(
const { defaultActions, postTypeObject, userCanCreatePostType } = useSelect(
( select ) => {
const { getPostType, canUser, getCachedResolvers } =
select( coreStore );
const { getPostType, canUser } = select( coreStore );
const { getEntityActions } = unlock( select( editorStore ) );
const _postTypeObject = getPostType( postType );
return {
postTypeObject: _postTypeObject,
postTypeObject: getPostType( postType ),
defaultActions: getEntityActions( 'postType', postType ),
userCanCreatePostType: canUser( 'create', {
kind: 'postType',
name: postType,
} ),
cachedCanUserResolvers: getCachedResolvers()?.canUser,
};
},
[ postType ]
Expand Down Expand Up @@ -798,9 +790,6 @@ export function usePostActions( { postType, onActionPerformed, context } ) {
}

return actions;
// We are making this use memo depend on cachedCanUserResolvers as a way to make the component using this hook re-render
// when user capabilities are resolved. This makes sure the isEligible functions of actions dependent on capabilities are re-evaluated.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
defaultActions,
userCanCreatePostType,
Expand All @@ -814,6 +803,5 @@ export function usePostActions( { postType, onActionPerformed, context } ) {
supportsRevisions,
supportsTitle,
context,
cachedCanUserResolvers,
] );
}

0 comments on commit f070092

Please sign in to comment.