Skip to content

Commit

Permalink
Editor: Optimize 'PostAuthorCheck' component data selection (#69105)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
  • Loading branch information
3 people authored Feb 10, 2025
1 parent 594a4d8 commit aa89fdc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/editor/src/components/post-author/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ import { AUTHORS_QUERY } from './constants';
export default function PostAuthorCheck( { children } ) {
const { hasAssignAuthorAction, hasAuthors } = useSelect( ( select ) => {
const post = select( editorStore ).getCurrentPost();
const authors = select( coreStore ).getUsers( AUTHORS_QUERY );
const canAssignAuthor = post?._links?.[ 'wp:action-assign-author' ]
? true
: false;
return {
hasAssignAuthorAction:
post._links?.[ 'wp:action-assign-author' ] ?? false,
hasAuthors: authors?.length >= 1,
hasAssignAuthorAction: canAssignAuthor,
hasAuthors: canAssignAuthor
? select( coreStore ).getUsers( AUTHORS_QUERY )?.length >= 1
: false,
};
}, [] );

Expand Down

0 comments on commit aa89fdc

Please sign in to comment.