Skip to content

Commit

Permalink
Fix selector
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jul 26, 2024
1 parent 239ddee commit a78b7ed
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions packages/core-data/src/private-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { createSelector, createRegistrySelector } from '@wordpress/data';
/**
* Internal dependencies
*/
import { canUser } from './selectors';
import type { State } from './selectors';
import { STORE_NAME } from './name';

Expand Down Expand Up @@ -55,20 +54,22 @@ export const getBlockPatternsForPostType = createRegistrySelector(
/**
* Returns the entity records permissions for the given entity record ids.
*/
export const getEntityRecordsPermissions = createSelector(
( state: State, kind: string, name: string, ids: string[] ) => {
return ids.map( ( id ) => ( {
delete: canUser( state, 'delete', {
kind,
name,
id,
} ),
update: canUser( state, 'update', {
kind,
name,
id,
} ),
} ) );
},
( state ) => [ state.userPermissions ]
export const getEntityRecordsPermissions = createRegistrySelector( ( select ) =>
createSelector(
( state: State, kind: string, name: string, ids: string[] ) => {
return ids.map( ( id ) => ( {
delete: select( STORE_NAME ).canUser( 'delete', {
kind,
name,
id,
} ),
update: select( STORE_NAME ).canUser( 'update', {
kind,
name,
id,
} ),
} ) );
},
( state ) => [ state.userPermissions ]
)
);

0 comments on commit a78b7ed

Please sign in to comment.