Skip to content

Commit

Permalink
Make isSavingPost true during entire save, not only when saving the e…
Browse files Browse the repository at this point in the history
…ntity
  • Loading branch information
jsnajdr committed Oct 20, 2022
1 parent 4c87ab6 commit bdc01b7
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions packages/editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,15 +681,9 @@ export function isDeletingPost( state ) {
*
* @return {boolean} Whether post is being saved.
*/
export const isSavingPost = createRegistrySelector( ( select ) => ( state ) => {
const postType = getCurrentPostType( state );
const postId = getCurrentPostId( state );
return select( coreStore ).isSavingEntityRecord(
'postType',
postType,
postId
);
} );
export function isSavingPost( state ) {
return !! state.saving.pending;
}

/**
* Returns true if non-post entities are currently being saved, or false otherwise.
Expand Down Expand Up @@ -760,10 +754,7 @@ export const didPostSaveRequestFail = createRegistrySelector(
* @return {boolean} Whether the post is autosaving.
*/
export function isAutosavingPost( state ) {
if ( ! isSavingPost( state ) ) {
return false;
}
return Boolean( state.saving.options?.isAutosave );
return isSavingPost( state ) && Boolean( state.saving.options?.isAutosave );
}

/**
Expand All @@ -774,10 +765,7 @@ export function isAutosavingPost( state ) {
* @return {boolean} Whether the post is being previewed.
*/
export function isPreviewingPost( state ) {
if ( ! isSavingPost( state ) ) {
return false;
}
return Boolean( state.saving.options?.isPreview );
return isSavingPost( state ) && Boolean( state.saving.options?.isPreview );
}

/**
Expand Down

0 comments on commit bdc01b7

Please sign in to comment.