From 7b4bb191500c6bc81f372c75d6937d6472d0e24c Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Wed, 23 May 2018 23:34:06 -0400 Subject: [PATCH] Add isEditedPostSaveable logic to isPostAutosaveable --- editor/components/autosave-monitor/index.js | 7 ++----- editor/store/selectors.js | 5 +++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/editor/components/autosave-monitor/index.js b/editor/components/autosave-monitor/index.js index 2c70e657d0fc0..777061baa12fc 100644 --- a/editor/components/autosave-monitor/index.js +++ b/editor/components/autosave-monitor/index.js @@ -6,7 +6,7 @@ import { withSelect, withDispatch } from '@wordpress/data'; export class AutosaveMonitor extends Component { componentDidUpdate( prevProps ) { - const { isDirty, isSaveable, isAutosaveable, isAutosaving } = this.props; + const { isDirty, isAutosaveable, isAutosaving } = this.props; // Prevent autosaves if an autosave is in progress. if ( isAutosaving ) { @@ -14,10 +14,9 @@ export class AutosaveMonitor extends Component { } if ( prevProps.isDirty !== isDirty || - prevProps.isSaveable !== isSaveable || prevProps.isAutosaveable !== isAutosaveable ) { - this.toggleTimer( isDirty && isSaveable && isAutosaveable ); + this.toggleTimer( isDirty && isAutosaveable ); } } @@ -45,7 +44,6 @@ export default compose( [ withSelect( ( select ) => { const { isEditedPostDirty, - isEditedPostSaveable, isPostAutosaveable, getEditorSettings, isAutosavingPost, @@ -53,7 +51,6 @@ export default compose( [ const { autosaveInterval } = getEditorSettings(); return { isDirty: isEditedPostDirty(), - isSaveable: isEditedPostSaveable(), isAutosaveable: isPostAutosaveable(), autosaveInterval: autosaveInterval, isAutosaving: isAutosavingPost(), diff --git a/editor/store/selectors.js b/editor/store/selectors.js index b04c4d4ad6224..c5c844e22bd30 100644 --- a/editor/store/selectors.js +++ b/editor/store/selectors.js @@ -312,6 +312,11 @@ export function isPostAutosaveable( state ) { return false; } + // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving. + if ( ! isEditedPostSaveable( state ) ) { + return false; + } + // If we don't already have an autosave, the post is autosaveable. if ( ! hasAutosave( state ) ) { return true;