diff --git a/packages/edit-post/src/store/actions.js b/packages/edit-post/src/store/actions.js index d00f7472382f8..1dc0401baf21c 100644 --- a/packages/edit-post/src/store/actions.js +++ b/packages/edit-post/src/store/actions.js @@ -8,7 +8,7 @@ import { privateApis as editorPrivateApis, } from '@wordpress/editor'; import deprecated from '@wordpress/deprecated'; -import { addFilter } from '@wordpress/hooks'; +import { addAction } from '@wordpress/hooks'; import { store as coreStore } from '@wordpress/core-data'; /** @@ -478,21 +478,14 @@ export const initializeMetaBoxes = metaBoxesInitialized = true; // Save metaboxes on save completion, except for autosaves. - addFilter( - 'editor.__unstableSavePost', + addAction( + 'editor.savePost', 'core/edit-post/save-metaboxes', - ( previous, options ) => - previous.then( () => { - if ( options.isAutosave ) { - return; - } - - if ( ! select.hasMetaBoxes() ) { - return; - } - - return dispatch.requestMetaBoxUpdates(); - } ) + async ( options ) => { + if ( ! options.isAutosave && select.hasMetaBoxes() ) { + await dispatch.requestMetaBoxUpdates(); + } + } ); dispatch( { diff --git a/packages/editor/src/store/actions.js b/packages/editor/src/store/actions.js index 0851c977b7a44..fa720e1fc7d34 100644 --- a/packages/editor/src/store/actions.js +++ b/packages/editor/src/store/actions.js @@ -12,7 +12,11 @@ import { import { store as noticesStore } from '@wordpress/notices'; import { store as coreStore } from '@wordpress/core-data'; import { store as blockEditorStore } from '@wordpress/block-editor'; -import { applyFilters } from '@wordpress/hooks'; +import { + applyFilters, + applyFiltersAsync, + doActionAsync, +} from '@wordpress/hooks'; import { store as preferencesStore } from '@wordpress/preferences'; import { __ } from '@wordpress/i18n'; @@ -199,9 +203,9 @@ export const savePost = let error = false; try { - edits = await applyFilters( + edits = await applyFiltersAsync( 'editor.preSavePost', - Promise.resolve( edits ), + edits, options ); } catch ( err ) { @@ -251,11 +255,7 @@ export const savePost = if ( ! error ) { try { - await applyFilters( - 'editor.savePost', - Promise.resolve(), - options - ); + await doActionAsync( 'editor.savePost', options ); } catch ( err ) { error = err; }