Skip to content

Commit

Permalink
Prevent autosaves if an autosave is in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Silverstein committed May 23, 2018
1 parent 20f2b43 commit f669754
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion editor/components/autosave-monitor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { withSelect, withDispatch } from '@wordpress/data';

export class AutosaveMonitor extends Component {
componentDidUpdate( prevProps ) {
const { isDirty, isSaveable, isAutosaveable } = this.props;
const { isDirty, isSaveable, isAutosaveable, isAutosaving } = this.props;

// Prevent autosaves if an autosave is in progress.
if ( isAutosaving ) {
return;
}
if (
prevProps.isDirty !== isDirty ||
prevProps.isSaveable !== isSaveable ||
Expand Down Expand Up @@ -43,13 +48,15 @@ export default compose( [
isEditedPostSaveable,
isPostAutosaveable,
getEditorSettings,
isAutosavingPost,
} = select( 'core/editor' );
const { autosaveInterval } = getEditorSettings();
return {
isDirty: isEditedPostDirty(),
isSaveable: isEditedPostSaveable(),
isAutosaveable: isPostAutosaveable(),
autosaveInterval: autosaveInterval,
isAutosaving: isAutosavingPost(),
};
} ),

Expand Down

0 comments on commit f669754

Please sign in to comment.