diff --git a/packages/core-data/src/actions.js b/packages/core-data/src/actions.js index 02ad7d31768599..a56709e0b1d81e 100644 --- a/packages/core-data/src/actions.js +++ b/packages/core-data/src/actions.js @@ -260,7 +260,7 @@ export function* saveEntityRecord( // have a value. let data = { ...persistedRecord, ...autosavePost, ...record }; data = Object.keys( data ).reduce( ( acc, key ) => { - if ( key in [ 'title', 'excerpt', 'content' ] ) { + if ( [ 'title', 'excerpt', 'content' ].includes( key ) ) { acc[ key ] = get( data[ key ], 'raw', data[ key ] ); } return acc; @@ -281,10 +281,11 @@ export function* saveEntityRecord( } if ( getNoticeActionArgs ) { - const args = getNoticeActionArgs( + const postType = updatedRecord.type || persistedRecord.type; + const args = postType && getNoticeActionArgs( persistedRecord, updatedRecord, - yield select( 'getPostType', updatedRecord.type ) + yield select( 'getPostType', postType ) ); if ( args && args.length ) { yield dispatch( diff --git a/packages/editor/src/store/selectors.js b/packages/editor/src/store/selectors.js index c4bf57dfb2f687..003bd720861b99 100644 --- a/packages/editor/src/store/selectors.js +++ b/packages/editor/src/store/selectors.js @@ -347,12 +347,7 @@ export function getEditedPostAttribute( state, attributeName ) { * @return {*} Autosave attribute value. */ export const getAutosaveAttribute = createRegistrySelector( ( select ) => ( state, attributeName ) => { - deprecated( '`wp.data.select( \'core/editor\' ).getAutosaveAttribute( attributeName )`', { - alternative: '`wp.data.select( \'core\' ).getAutosave( postType, postId, userId )`', - plugin: 'Gutenberg', - } ); - - if ( ! includes( AUTOSAVE_PROPERTIES, attributeName ) ) { + if ( ! includes( AUTOSAVE_PROPERTIES, attributeName ) && attributeName !== 'preview_link' ) { return; } @@ -747,7 +742,7 @@ export function getEditedPostPreviewLink( state ) { return; } - let previewLink = getEditedPostAttribute( state, 'preview_link' ); + let previewLink = getAutosaveAttribute( state, 'preview_link' ); if ( ! previewLink ) { previewLink = getEditedPostAttribute( state, 'link' ); if ( previewLink ) {