Skip to content

Commit

Permalink
Editor: Receive saved post into Redux state
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jun 20, 2016
1 parent 6881e69 commit 8cd146f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions client/post-editor/post-editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ const PostEditor = React.createClass( {
} );
},

componentWillUpdate( nextProps, nextState ) {
const { isNew, savedPost } = nextState;
if ( ! isNew && savedPost && savedPost !== this.state.savedPost ) {
nextProps.receivePost( savedPost );
}
},

componentDidMount: function() {
debug( 'PostEditor react component mounted.' );
// if content is passed in, e.g., through url param
Expand Down Expand Up @@ -815,6 +822,9 @@ const PostEditor = React.createClass( {
this.props.setEditorPostId( post.ID );
}

// Receive updated post into state
this.props.receivePost( post );

// make sure the history entry has the post ID in it, but don't dispatch
page.replace(
basePath + '/' + this.props.sites.getSite( post.site_ID ).slug + '/' + post.ID,
Expand Down

0 comments on commit 8cd146f

Please sign in to comment.