From ddedead709b42184368a4aab3f5cf03ed75295a8 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Sun, 2 Jul 2023 10:52:50 +0200 Subject: [PATCH] Make use of accessing private APIs from thunks directly --- packages/block-editor/src/store/actions.js | 3 +-- packages/block-editor/src/store/test/actions.js | 3 +++ packages/core-data/src/actions.js | 7 ++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/block-editor/src/store/actions.js b/packages/block-editor/src/store/actions.js index 9dd3b24009c51..1d7ec460fe8d9 100644 --- a/packages/block-editor/src/store/actions.js +++ b/packages/block-editor/src/store/actions.js @@ -28,7 +28,6 @@ import { } from '../utils/selection'; import { __experimentalUpdateSettings, - ensureDefaultBlock, privateRemoveBlocks, } from './private-actions'; @@ -403,7 +402,7 @@ export const replaceBlocks = initialPosition, meta, } ); - dispatch( ensureDefaultBlock() ); + dispatch.ensureDefaultBlock(); }; /** diff --git a/packages/block-editor/src/store/test/actions.js b/packages/block-editor/src/store/test/actions.js index fc15737eda8d2..48fc234e0e6c2 100644 --- a/packages/block-editor/src/store/test/actions.js +++ b/packages/block-editor/src/store/test/actions.js @@ -216,6 +216,7 @@ describe( 'actions', () => { getBlockCount: () => 1, }; const dispatch = jest.fn(); + dispatch.ensureDefaultBlock = jest.fn(); replaceBlock( 'chicken', block )( { select, dispatch } ); @@ -281,6 +282,7 @@ describe( 'actions', () => { getBlockCount: () => 1, }; const dispatch = jest.fn(); + dispatch.ensureDefaultBlock = jest.fn(); replaceBlocks( [ 'chicken' ], blocks )( { select, dispatch } ); @@ -314,6 +316,7 @@ describe( 'actions', () => { getBlockCount: () => 1, }; const dispatch = jest.fn(); + dispatch.ensureDefaultBlock = jest.fn(); replaceBlocks( [ 'chicken' ], diff --git a/packages/core-data/src/actions.js b/packages/core-data/src/actions.js index cfab95aae9f8f..79b113175b885 100644 --- a/packages/core-data/src/actions.js +++ b/packages/core-data/src/actions.js @@ -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. @@ -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; } @@ -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; }