Skip to content

Commit

Permalink
Make use of accessing private APIs from thunks directly
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Jul 2, 2023
1 parent 9a6958e commit ddedead
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/block-editor/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
} from '../utils/selection';
import {
__experimentalUpdateSettings,
ensureDefaultBlock,
privateRemoveBlocks,
} from './private-actions';

Expand Down Expand Up @@ -403,7 +402,7 @@ export const replaceBlocks =
initialPosition,
meta,
} );
dispatch( ensureDefaultBlock() );
dispatch.ensureDefaultBlock();
};

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/block-editor/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ describe( 'actions', () => {
getBlockCount: () => 1,
};
const dispatch = jest.fn();
dispatch.ensureDefaultBlock = jest.fn();

replaceBlock( 'chicken', block )( { select, dispatch } );

Expand Down Expand Up @@ -281,6 +282,7 @@ describe( 'actions', () => {
getBlockCount: () => 1,
};
const dispatch = jest.fn();
dispatch.ensureDefaultBlock = jest.fn();

replaceBlocks( [ 'chicken' ], blocks )( { select, dispatch } );

Expand Down Expand Up @@ -314,6 +316,7 @@ describe( 'actions', () => {
getBlockCount: () => 1,
};
const dispatch = jest.fn();
dispatch.ensureDefaultBlock = jest.fn();

replaceBlocks(
[ 'chicken' ],
Expand Down
7 changes: 2 additions & 5 deletions packages/core-data/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { receiveItems, removeItems, receiveQueriedItems } from './queried-data';
import { getOrLoadEntitiesConfig, DEFAULT_ENTITY_KEY } from './entities';
import { createBatch } from './batch';
import { STORE_NAME } from './name';
import { getUndoEdits, getRedoEdits } from './private-selectors';

/**
* Returns an action object used in signalling that authors have been received.
Expand Down Expand Up @@ -407,8 +406,7 @@ export const editEntityRecord =
export const undo =
() =>
( { select, dispatch } ) => {
// Todo: we shouldn't have to pass "root" here.
const undoEdit = select( ( state ) => getUndoEdits( state.root ) );
const undoEdit = select.getUndoEdits();
if ( ! undoEdit ) {
return;
}
Expand All @@ -425,8 +423,7 @@ export const undo =
export const redo =
() =>
( { select, dispatch } ) => {
// Todo: we shouldn't have to pass "root" here.
const redoEdit = select( ( state ) => getRedoEdits( state.root ) );
const redoEdit = select.getRedoEdits();
if ( ! redoEdit ) {
return;
}
Expand Down

0 comments on commit ddedead

Please sign in to comment.