Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Integrate dirty state, API requests, and publish button
- Make `SavedState` aware of API requests
- Make `PublishButton` aware of `dirty` state
  • Loading branch information
nylen committed May 7, 2017
commit 66a4f0cbd81428c0313220e04c6bee390f8fb4c6
6 changes: 4 additions & 2 deletions editor/header/tools/publish-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { savePost } from 'actions';
function PublishButton( {
post,
edits,
dirty,
blocks,
isSuccessful,
isRequesting,
Expand All @@ -27,11 +28,11 @@ function PublishButton( {
buttonText = requestIsNewPost
? wp.i18n.__( 'Saving…' )
: wp.i18n.__( 'Updating…' );
} else if ( isSuccessful ) {
} else if ( ! dirty && isSuccessful ) {
buttonText = requestIsNewPost
? wp.i18n.__( 'Saved!' )
: wp.i18n.__( 'Updated!' );
} else if ( isError ) {
} else if ( ! dirty && isError ) {
buttonText = requestIsNewPost
? wp.i18n.__( 'Save failed' )
: wp.i18n.__( 'Update failed' );
Expand Down Expand Up @@ -63,6 +64,7 @@ export default connect(
( state ) => ( {
post: state.currentPost,
edits: state.editor.edits,
dirty: state.editor.dirty,
blocks: state.editor.blockOrder.map( ( uid ) => (
state.editor.blocksByUid[ uid ]
) ),
Expand Down
1 change: 1 addition & 0 deletions editor/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const editor = combineUndoableReducers( {
dirty( state = false, action ) {
switch ( action.type ) {
case 'RESET_BLOCKS':
case 'REQUEST_POST_UPDATE_SUCCESS':
return false;

case 'UPDATE_BLOCK':
Expand Down