diff --git a/editor/store/effects.js b/editor/store/effects.js index b67c697b3ba27..dd4531055d87b 100644 --- a/editor/store/effects.js +++ b/editor/store/effects.js @@ -174,6 +174,11 @@ export default { const { previousPost, post, isAutosave } = action; const { dispatch } = store; + // Autosaves are neither shown a notice nor redirected. + if ( isAutosave ) { + return; + } + const publishStatus = [ 'publish', 'private', 'future' ]; const isPublished = includes( publishStatus, previousPost.status ); const willPublish = includes( publishStatus, post.status ); @@ -181,8 +186,8 @@ export default { let noticeMessage; let shouldShowLink = true; - if ( isAutosave || ( ! isPublished && ! willPublish ) ) { - // If autosaving or saving a non-published post, don't show notice. + if ( ! isPublished && ! willPublish ) { + // If saving a non-published post, don't show notice. noticeMessage = null; } else if ( isPublished && ! willPublish ) { // If undoing publish status, show specific notice diff --git a/editor/store/test/effects.js b/editor/store/test/effects.js index 310916655a0b4..4a25a91137079 100644 --- a/editor/store/test/effects.js +++ b/editor/store/test/effects.js @@ -359,6 +359,19 @@ describe( 'effects', () => { type: 'CREATE_NOTICE', } ) ); } ); + + it( 'should do nothing if the updated post was autosaved', () => { + const dispatch = jest.fn(); + const store = { dispatch }; + + const previousPost = getPublishedPost(); + const post = { ...getPublishedPost(), id: defaultPost.id + 1 }; + + handler( { post, previousPost, isAutosave: true }, store ); + + expect( dispatch ).toHaveBeenCalledTimes( 0 ); + expect( replaceStateSpy ).toHaveBeenCalledTimes( 0 ); + } ); } ); describe( '.REQUEST_POST_UPDATE_FAILURE', () => {