Skip to content

Commit

Permalink
Address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jan 24, 2024
1 parent 5d3dc07 commit f6ec31e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
11 changes: 4 additions & 7 deletions packages/block-editor/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,13 +321,10 @@ export const getAllPatterns = createRegistrySelector( ( select ) =>
};
}
);
return [
...userPatterns,
...__experimentalBlockPatterns,
...unlock( select( store ) ).getFetchedPatterns(
__experimentalFetchBlockPatterns
),
];
const blockPatterns = __experimentalFetchBlockPatterns
? unlock( select( store ) ).getFetchedPatterns()
: __experimentalBlockPatterns;
return [ ...userPatterns, ...blockPatterns ];
}, getAllPatternsDependants )
);

Expand Down
17 changes: 14 additions & 3 deletions packages/block-editor/src/store/resolvers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
export const getFetchedPatterns =
( fetch ) =>
async ( { dispatch } ) => {
const patterns = await fetch();
() =>
async ( { dispatch, select } ) => {
const { __experimentalFetchBlockPatterns } = select.getSettings();
if ( ! __experimentalFetchBlockPatterns ) {
return;
}
const patterns = await __experimentalFetchBlockPatterns();
dispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );
};

getFetchedPatterns.shouldInvalidate = ( action ) => {
return (
action.type === 'UPDATE_SETTINGS' &&
!! action.settings.__experimentalFetchBlockPatterns
);
};

0 comments on commit f6ec31e

Please sign in to comment.