Skip to content

Commit

Permalink
Editor: Skip content parse at save-time content edit
Browse files Browse the repository at this point in the history
Edited content is not synced until save, and since is derived _from_ the blocks state is not necessary to incur a subsequent parse / block reset. This occurred previously at update step, but must occur at the edit. Subsequent update should also skip parse, and will since content has not changed.
  • Loading branch information
aduth committed Aug 28, 2018
1 parent 5337b31 commit b1c2fa0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions packages/editor/src/store/effects/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import { BEGIN, COMMIT, REVERT } from 'redux-optimist';
import { pick, includes, merge } from 'lodash';
import { pick, includes } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -88,7 +88,9 @@ export const requestPostUpdate = async ( action, store ) => {
// such that it is considered synced at the time of the optimistic update,
// and divergences in the persisted value are accounted for in the post
// reset which follows (i.e. mark as dirty if saved content differs).
dispatch( editPost( { content } ) );
// Bypass blocks parsing since the updated content is derived from blocks
// from state, thus is assumed to be in sync.
dispatch( editPost( { content }, { skipContentParse: true } ) );

let toSend = {
...edits,
Expand All @@ -106,12 +108,11 @@ export const requestPostUpdate = async ( action, store ) => {

// Optimistically apply updates under the assumption that the post will be
// updated. See below logic in success resolution for revert if autosave is
// applied as a revision. Bypass blocks parsing since the updated content
// is derived from blocks from state, thus is assumed to be in sync.
dispatch( merge( updatePost( toSend ), {
// applied as a revision.
dispatch( {
...updatePost( toSend ),
optimist: { id: POST_UPDATE_TRANSACTION_ID },
options: { skipContentParse: true },
} ) );
} );

let request;
if ( isAutosave ) {
Expand Down

0 comments on commit b1c2fa0

Please sign in to comment.