Skip to content

Commit

Permalink
Core Data: Fix autosaves filtering.
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras committed Aug 8, 2019
1 parent 1045a01 commit 56d0e9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
7 changes: 4 additions & 3 deletions packages/core-data/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand Down
9 changes: 2 additions & 7 deletions packages/editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit 56d0e9e

Please sign in to comment.