From b1c2fa042b30a9d8e7ffe33382a2a4d060427887 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Tue, 28 Aug 2018 13:01:36 -0400 Subject: [PATCH] Editor: Skip content parse at save-time content edit 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. --- packages/editor/src/store/effects/posts.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/editor/src/store/effects/posts.js b/packages/editor/src/store/effects/posts.js index c048f7bccf59a8..f5e67aef136ac6 100644 --- a/packages/editor/src/store/effects/posts.js +++ b/packages/editor/src/store/effects/posts.js @@ -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 @@ -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, @@ -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 ) {