Skip to content

Commit

Permalink
Fix forgotten line removal from #31078
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Apr 23, 2021
1 parent e10f14c commit 8bf2e85
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions packages/editor/src/components/local-autosave-monitor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { store as noticesStore } from '@wordpress/notices';
*/
import AutosaveMonitor from '../autosave-monitor';
import { localAutosaveGet, localAutosaveClear } from '../../store/controls';
import { store as editorStore } from '../../store';

const requestIdleCallback = window.requestIdleCallback
? window.requestIdleCallback
Expand Down Expand Up @@ -47,20 +48,23 @@ const hasSessionStorageSupport = once( () => {
*/
function useAutosaveNotice() {
const { postId, isEditedPostNew, hasRemoteAutosave } = useSelect(
( select ) => ( {
postId: select( 'core/editor' ).getCurrentPostId(),
isEditedPostNew: select( 'core/editor' ).isEditedPostNew(),
getEditedPostAttribute: select( 'core/editor' )
.getEditedPostAttribute,
hasRemoteAutosave: !! select( 'core/editor' ).getEditorSettings()
.autosave,
} ),
( select ) => {
const {
getCurrentPostId,
_isEditedPostNew,
getEditorSettings,
} = select( editorStore );
return {
postId: getCurrentPostId(),
isEditedPostNew: _isEditedPostNew(),
hasRemoteAutosave: !! getEditorSettings().autosave,
};
},
[]
);
const { getEditedPostAttribute } = useSelect( 'core/editor' );

const { getEditedPostAttribute } = useSelect( editorStore );
const { createWarningNotice, removeNotice } = useDispatch( noticesStore );
const { editPost, resetEditorBlocks } = useDispatch( 'core/editor' );
const { editPost, resetEditorBlocks } = useDispatch( editorStore );

useEffect( () => {
let localAutosave = localAutosaveGet( postId, isEditedPostNew );
Expand Down Expand Up @@ -128,16 +132,22 @@ function useAutosavePurge() {
isDirty,
isAutosaving,
didError,
} = useSelect(
( select ) => ( {
postId: select( 'core/editor' ).getCurrentPostId(),
isEditedPostNew: select( 'core/editor' ).isEditedPostNew(),
isDirty: select( 'core/editor' ).isEditedPostDirty(),
isAutosaving: select( 'core/editor' ).isAutosavingPost(),
didError: select( 'core/editor' ).didPostSaveRequestFail(),
} ),
[]
);
} = useSelect( ( select ) => {
const {
getCurrentPostId,
_isEditedPostNew,
isEditedPostDirty,
isAutosavingPost,
didPostSaveRequestFail,
} = select( editorStore );
return {
postId: getCurrentPostId(),
isEditedPostNew: _isEditedPostNew(),
isDirty: isEditedPostDirty(),
isAutosaving: isAutosavingPost(),
didError: didPostSaveRequestFail(),
};
}, [] );

const lastIsDirty = useRef( isDirty );
const lastIsAutosaving = useRef( isAutosaving );
Expand Down Expand Up @@ -166,18 +176,17 @@ function useAutosavePurge() {
}

function LocalAutosaveMonitor() {
const { autosave } = useDispatch( 'core/editor' );
const { autosave } = useDispatch( editorStore );
const deferedAutosave = useCallback( () => {
requestIdleCallback( () => autosave( { local: true } ) );
}, [] );
useAutosaveNotice();
useAutosavePurge();

const { localAutosaveInterval } = useSelect(
( select ) => ( {
localAutosaveInterval: select( 'core/editor' ).getEditorSettings()
const localAutosaveInterval = useSelect(
( select ) =>
select( editorStore ).getEditorSettings()
.__experimentalLocalAutosaveInterval,
} ),
[]
);

Expand Down

0 comments on commit 8bf2e85

Please sign in to comment.