From 91750ac457fddd9a21735de0cb63056c26bab349 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Tue, 30 Jul 2024 14:27:26 +0400 Subject: [PATCH] Core Data: Fix 'getEntityRecordPermissions' memoization --- packages/core-data/src/private-selectors.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core-data/src/private-selectors.ts b/packages/core-data/src/private-selectors.ts index 7eb67973c67281..841f4ee2ef460d 100644 --- a/packages/core-data/src/private-selectors.ts +++ b/packages/core-data/src/private-selectors.ts @@ -57,7 +57,8 @@ export const getBlockPatternsForPostType = createRegistrySelector( export const getEntityRecordsPermissions = createRegistrySelector( ( select ) => createSelector( ( state: State, kind: string, name: string, ids: string[] ) => { - return ids.map( ( id ) => ( { + const normalizedIds = Array.isArray( ids ) ? ids : [ ids ]; + return normalizedIds.map( ( id ) => ( { delete: select( STORE_NAME ).canUser( 'delete', { kind, name, @@ -90,5 +91,5 @@ export function getEntityRecordPermissions( name: string, id: string ) { - return getEntityRecordsPermissions( state, kind, name, [ id ] )[ 0 ]; + return getEntityRecordsPermissions( state, kind, name, id )[ 0 ]; }