From aa89fdc9dcb3bf72043883e3818de1ab9dc42a18 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Mon, 10 Feb 2025 08:08:19 +0400 Subject: [PATCH] Editor: Optimize 'PostAuthorCheck' component data selection (#69105) Co-authored-by: Mamaduka Co-authored-by: t-hamano --- packages/editor/src/components/post-author/check.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/components/post-author/check.js b/packages/editor/src/components/post-author/check.js index 0ae7a3963e243f..de781038d2dfd5 100644 --- a/packages/editor/src/components/post-author/check.js +++ b/packages/editor/src/components/post-author/check.js @@ -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, }; }, [] );