Skip to content

Commit

Permalink
Fix dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Feb 1, 2024
1 parent d355bc9 commit fef6b2a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
} );
},
( state, rootClientId ) => [
getAllPatternsDependants( state ),
getAllPatternsDependants( select )( state ),
state.settings.allowedBlockTypes,
state.settings.templateLock,
state.blockListSettings[ rootClientId ],
Expand Down Expand Up @@ -325,7 +325,7 @@ export const getAllPatterns = createRegistrySelector( ( select ) =>
( x, index, arr ) =>
index === arr.findIndex( ( y ) => x.name === y.name )
);
}, getAllPatternsDependants )
}, getAllPatternsDependants( select ) )
);

const EMPTY_ARRAY = [];
Expand Down
12 changes: 6 additions & 6 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -2321,12 +2321,12 @@ export const __experimentalGetParsedPattern = createRegistrySelector(
__unstableSkipMigrationLogs: true,
} ),
};
}, getAllPatternsDependants )
}, getAllPatternsDependants( select ) )
);

const getAllowedPatternsDependants = ( state, rootClientId ) => {
const getAllowedPatternsDependants = ( select ) => ( state, rootClientId ) => {
return [
...getAllPatternsDependants( state ),
...getAllPatternsDependants( select )( state ),
state.settings.allowedBlockTypes,
state.settings.templateLock,
state.blockListSettings[ rootClientId ],
Expand Down Expand Up @@ -2367,7 +2367,7 @@ export const __experimentalGetAllowedPatterns = createRegistrySelector(
);

return patternsAllowed;
}, getAllowedPatternsDependants );
}, getAllowedPatternsDependants( select ) );
}
);

Expand Down Expand Up @@ -2406,7 +2406,7 @@ export const getPatternsByBlockTypes = createRegistrySelector( ( select ) =>
return filteredPatterns;
},
( state, blockNames, rootClientId ) =>
getAllowedPatternsDependants( state, rootClientId )
getAllowedPatternsDependants( select )( state, rootClientId )
)
);

Expand Down Expand Up @@ -2480,7 +2480,7 @@ export const __experimentalGetPatternTransformItems = createRegistrySelector(
);
},
( state, blocks, rootClientId ) =>
getAllowedPatternsDependants( state, rootClientId )
getAllowedPatternsDependants( select )( state, rootClientId )
)
);

Expand Down
9 changes: 8 additions & 1 deletion packages/block-editor/src/store/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Internal dependencies
*/
import { unlock } from '../lock-unlock';
import { STORE_NAME } from './constants';

export const checkAllowList = ( list, item, defaultResult = null ) => {
if ( typeof list === 'boolean' ) {
return list;
Expand Down Expand Up @@ -40,12 +46,13 @@ export const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
return true;
};

export const getAllPatternsDependants = ( state ) => {
export const getAllPatternsDependants = ( select ) => ( state ) => {
return [
state.settings.__experimentalBlockPatterns,
state.settings.__experimentalUserPatternCategories,
state.settings.__experimentalReusableBlocks,
state.settings.__experimentalFetchBlockPatterns,
state.blockPatterns,
unlock( select( STORE_NAME ) ).getReusableBlocks(),
];
};

0 comments on commit fef6b2a

Please sign in to comment.