Skip to content

Commit

Permalink
respect AUTOSAVE_INTERVAL for autosave timing
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Silverstein committed May 14, 2018
1 parent c81ab2a commit d795e1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions editor/components/autosave-monitor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export class AutosaveMonitor extends Component {

toggleTimer( isPendingSave ) {
clearTimeout( this.pendingSave );

const { editorSettings } = this.props;
if ( isPendingSave ) {
this.pendingSave = setTimeout(
() => this.props.autosave(),
10000
editorSettings.autosaveInterval * 1000
);
}
}
Expand All @@ -38,11 +38,17 @@ export class AutosaveMonitor extends Component {

export default compose( [
withSelect( ( select ) => {
const { isEditedPostDirty, isEditedPostSaveable, isPostAutosaveable } = select( 'core/editor' );
const {
isEditedPostDirty,
isEditedPostSaveable,
isPostAutosaveable,
getEditorSettings
} = select( 'core/editor' );
return {
isDirty: isEditedPostDirty(),
isSaveable: isEditedPostSaveable(),
isAutosaveable: isPostAutosaveable(),
editorSettings: getEditorSettings(),
};
} ),

Expand Down
1 change: 1 addition & 0 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ function gutenberg_editor_scripts_and_styles( $hook ) {
'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title', 'gutenberg' ), $post ),
'bodyPlaceholder' => apply_filters( 'write_your_story', __( 'Write your story', 'gutenberg' ), $post ),
'isRTL' => is_rtl(),
'autosaveInterval' => defined( 'AUTOSAVE_INTERVAL' ) ? AUTOSAVE_INTERVAL : 60,
);

if ( ! empty( $color_palette ) ) {
Expand Down

0 comments on commit d795e1d

Please sign in to comment.