Skip to content

Commit

Permalink
Inserter: fix loading indicator for reusable blocks (#64839)
Browse files Browse the repository at this point in the history
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
Co-authored-by: jsnajdr <jsnajdr@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: kevin940726 <kevin940726@git.wordpress.org>
Co-authored-by: sathyapulse <sathyapulse@git.wordpress.org>
  • Loading branch information
6 people authored Sep 10, 2024
1 parent 2803537 commit 56c996f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 5 additions & 3 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,11 @@ const EMPTY_ARRAY = [];
export const getReusableBlocks = createRegistrySelector(
( select ) => ( state ) => {
const reusableBlocksSelect = state.settings[ reusableBlocksSelectKey ];
return reusableBlocksSelect
? reusableBlocksSelect( select )
: state.settings.__experimentalReusableBlocks ?? EMPTY_ARRAY;
return (
( reusableBlocksSelect
? reusableBlocksSelect( select )
: state.settings.__experimentalReusableBlocks ) ?? EMPTY_ARRAY
);
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ import { store as editorStore } from '../../store';
import { unlock } from '../../lock-unlock';
import { useGlobalStylesContext } from '../global-styles-provider';

const EMPTY_BLOCKS_LIST = [];
const EMPTY_OBJECT = {};

function __experimentalReusableBlocksSelect( select ) {
return (
select( coreStore ).getEntityRecords( 'postType', 'wp_block', {
per_page: -1,
} ) ?? EMPTY_BLOCKS_LIST
);
const { getEntityRecords, hasFinishedResolution } = select( coreStore );
const reusableBlocks = getEntityRecords( 'postType', 'wp_block', {
per_page: -1,
} );
return hasFinishedResolution( 'getEntityRecords', [
'postType',
'wp_block',
{ per_page: -1 },
] )
? reusableBlocks
: undefined;
}

const BLOCK_EDITOR_SETTINGS = [
Expand Down

0 comments on commit 56c996f

Please sign in to comment.