From bca2cd22624fa3b580d05135adcb0005d0a96cbe Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 22 Jun 2018 13:35:25 -0700 Subject: [PATCH] Only save metaboxes when it's not an autosave --- edit-post/store/effects.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/edit-post/store/effects.js b/edit-post/store/effects.js index 2143abc2018cef..60dd120e6b0654 100644 --- a/edit-post/store/effects.js +++ b/edit-post/store/effects.js @@ -54,10 +54,21 @@ const effects = { store.dispatch( setMetaBoxSavedData( dataPerLocation ) ); // Saving metaboxes when saving posts + const { isAutosavingPost } = select( 'core/editor' ); + let shouldRequestMetaBoxUpdates = false; subscribe( onChangeListener( select( 'core/editor' ).isSavingPost, ( isSavingPost ) => { - if ( ! isSavingPost ) { + // Only save metaboxes when this isn't an autosave. + if ( isSavingPost && ! isAutosavingPost( store.getState() ) ) { + shouldRequestMetaBoxUpdates = true; + } + // If a full save just completed, trigger metabox save. + if ( ! isSavingPost && shouldRequestMetaBoxUpdates ) { store.dispatch( requestMetaBoxUpdates() ); } + // Regardless of which save just occurred, reset metabox save state. + if ( ! isSavingPost ) { + shouldRequestMetaBoxUpdates = false; + } } ) ); }, REQUEST_META_BOX_UPDATES( action, store ) {