Skip to content

Commit

Permalink
Edit Site: Fix useEditedEntityRecord() loading state (#50730)
Browse files Browse the repository at this point in the history
* Edit Site: Fix useEditedEntityRecord() loading state

* Use hasFinishedResolution instead

* Also check for post ID
  • Loading branch information
tyxla authored May 18, 2023
1 parent 589fc18 commit 37a691f
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default function useEditedEntityRecord( postType, postId ) {
( select ) => {
const { getEditedPostType, getEditedPostId } =
select( editSiteStore );
const { getEditedEntityRecord } = select( coreStore );
const { getEditedEntityRecord, hasFinishedResolution } =
select( coreStore );
const { __experimentalGetTemplateInfo: getTemplateInfo } =
select( editorStore );
const usedPostType = postType ?? getEditedPostType();
Expand All @@ -26,7 +27,13 @@ export default function useEditedEntityRecord( postType, postId ) {
usedPostType,
usedPostId
);
const _isLoaded = !! usedPostId;
const _isLoaded =
usedPostId &&
hasFinishedResolution( 'getEditedEntityRecord', [
'postType',
usedPostType,
usedPostId,
] );
const templateInfo = getTemplateInfo( _record );

return {
Expand Down

0 comments on commit 37a691f

Please sign in to comment.