Skip to content

Commit

Permalink
Try to replace core/data with selectors from related stores
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jun 9, 2021
1 parent 5d170cc commit 6f9ba12
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
5 changes: 2 additions & 3 deletions packages/block-library/src/categories/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ export default function CategoriesEdit( {
} ) {
const selectId = useInstanceId( CategoriesEdit, 'blocks-category-select' );
const { categories, isRequesting } = useSelect( ( select ) => {
const { getEntityRecords } = select( coreStore );
const { isResolving } = select( 'core/data' );
const { getEntityRecords, isResolving } = select( coreStore );
const query = { per_page: -1, hide_empty: true };
return {
categories: getEntityRecords( 'taxonomy', 'category', query ),
isRequesting: isResolving( 'core', 'getEntityRecords', [
isRequesting: isResolving( 'getEntityRecords', [
'taxonomy',
'category',
query,
Expand Down
6 changes: 2 additions & 4 deletions packages/block-library/src/embed/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const EmbedEdit = ( props ) => {

const [ url, setURL ] = useState( attributesUrl );
const [ isEditingURL, setIsEditingURL ] = useState( false );
const { invalidateResolution } = useDispatch( 'core/data' );
const { invalidateResolution } = useDispatch( coreStore );

const {
preview,
Expand Down Expand Up @@ -214,9 +214,7 @@ const EmbedEdit = ( props ) => {
onChange={ ( event ) => setURL( event.target.value ) }
fallback={ () => fallback( url, onReplace ) }
tryAgain={ () => {
invalidateResolution( 'core', 'getEmbedPreview', [
url,
] );
invalidateResolution( 'getEmbedPreview', [ url ] );
} }
/>
</View>
Expand Down
6 changes: 1 addition & 5 deletions packages/core-data/src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ const EMPTY_ARRAY = [];
*/
export const isRequestingEmbedPreview = createRegistrySelector(
( select ) => ( state, url ) => {
return select( 'core/data' ).isResolving(
STORE_NAME,
'getEmbedPreview',
[ url ]
);
return select( STORE_NAME ).isResolving( 'getEmbedPreview', [ url ] );
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ function FullscreenModeClose( { showTooltip, icon, href } ) {
( select ) => {
const { getCurrentPostType } = select( editorStore );
const { isFeatureActive } = select( editPostStore );
const { isResolving } = select( 'core/data' );
const { getEntityRecord, getPostType } = select( coreStore );
const { getEntityRecord, getPostType, isResolving } = select(
coreStore
);
const siteData =
getEntityRecord( 'root', '__unstableBase', undefined ) || {};

return {
isActive: isFeatureActive( 'fullscreenMode' ),
isRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [
isRequestingSiteIcon: isResolving( 'getEntityRecord', [
'root',
'__unstableBase',
undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ function PostPublishPanelPrepublish( { children } ) {
siteTitle,
siteHome,
} = useSelect( ( select ) => {
const { isResolving } = select( 'core/data' );
const { getCurrentPost, isEditedPostBeingScheduled } = select(
editorStore
);
const { getEntityRecord } = select( coreStore );
const { getEntityRecord, isResolving } = select( coreStore );
const siteData =
getEntityRecord( 'root', '__unstableBase', undefined ) || {};

Expand All @@ -48,7 +47,7 @@ function PostPublishPanelPrepublish( { children } ) {
false
),
isBeingScheduled: isEditedPostBeingScheduled(),
isRequestingSiteIcon: isResolving( 'core', 'getEntityRecord', [
isRequestingSiteIcon: isResolving( 'getEntityRecord', [
'root',
'__unstableBase',
undefined,
Expand Down

0 comments on commit 6f9ba12

Please sign in to comment.