Skip to content

Commit

Permalink
Avoid running hasMetaBoxes on each subscribe (#15041)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Apr 19, 2019
1 parent a9671d6 commit 3f1964c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/edit-post/src/store/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ const effects = {

let wasSavingPost = select( 'core/editor' ).isSavingPost();
let wasAutosavingPost = select( 'core/editor' ).isAutosavingPost();

// Meta boxes are initialized once at page load. It is not necessary to
// account for updates on each state change.
//
// See: https://github.com/WordPress/WordPress/blob/5.1.1/wp-admin/includes/post.php#L2307-L2309
const hasActiveMetaBoxes = select( 'core/edit-post' ).hasMetaBoxes();
// Save metaboxes when performing a full save on the post.
subscribe( () => {
const isSavingPost = select( 'core/editor' ).isSavingPost();
const isAutosavingPost = select( 'core/editor' ).isAutosavingPost();
const hasActiveMetaBoxes = select( 'core/edit-post' ).hasMetaBoxes();

// Save metaboxes on save completion, except for autosaves that are not a post preview.
const shouldTriggerMetaboxesSave = (
Expand Down

0 comments on commit 3f1964c

Please sign in to comment.