Skip to content

Commit

Permalink
Editor: Remove redundant artificial dirtying
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Oct 23, 2018
1 parent 156a897 commit 3f2afc1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 26 deletions.
11 changes: 1 addition & 10 deletions packages/editor/src/store/effects/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,7 @@ export const requestPostUpdate = async ( action, store ) => {
*/
export const requestPostUpdateSuccess = ( action, store ) => {
const { previousPost, post, isAutosave, postType } = action;
const { dispatch, getState } = store;

// TEMPORARY: If edits remain after a save completes, the user must be
// prompted about unsaved changes. This should be refactored as part of
// the `isEditedPostDirty` selector instead.
//
// See: https://github.com/WordPress/gutenberg/issues/7409
if ( Object.keys( getPostEdits( getState() ) ).length ) {
dispatch( { type: 'DIRTY_ARTIFICIALLY' } );
}
const { dispatch } = store;

// Autosaves are neither shown a notice nor redirected.
if ( isAutosave ) {
Expand Down
3 changes: 0 additions & 3 deletions packages/editor/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,6 @@ export const editor = flow( [

return state;

case 'DIRTY_ARTIFICIALLY':
return { ...state };

case 'UPDATE_POST':
case 'RESET_POST':
const getCanonicalValue = action.type === 'UPDATE_POST' ?
Expand Down
13 changes: 0 additions & 13 deletions packages/editor/src/store/test/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,6 @@ describe( 'effects', () => {

expect( dispatch ).toHaveBeenCalledTimes( 0 );
} );

it( 'should dispatch dirtying action if edits linger after autosave', () => {
const dispatch = jest.fn();
const store = { dispatch, getState: createGetState( true ) };

const previousPost = getPublishedPost();
const post = { ...getPublishedPost(), id: defaultPost.id + 1 };

handler( { post, previousPost, isAutosave: true }, store );

expect( dispatch ).toHaveBeenCalledTimes( 1 );
expect( dispatch ).toHaveBeenCalledWith( { type: 'DIRTY_ARTIFICIALLY' } );
} );
} );

describe( '.REQUEST_POST_UPDATE_FAILURE', () => {
Expand Down

0 comments on commit 3f2afc1

Please sign in to comment.