Skip to content

Commit

Permalink
Comments Query: Pass queryPerPage to getEntityRecords
Browse files Browse the repository at this point in the history
  • Loading branch information
michalczaplinski committed Oct 27, 2021
1 parent ec7e7aa commit 1668cd3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/block-library/src/comment-template/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,28 @@ const TEMPLATE = [

export default function CommentTemplateEdit( {
clientId,
context: { postId },
context: { postId, queryPerPage },
} ) {
const innerBlocksProps = useInnerBlocksProps( {}, { template: TEMPLATE } );
const blockProps = useBlockProps();

const [ activeBlockContext, setActiveBlockContext ] = useState();

const { comments, blocks } = useSelect( ( select ) => {
const { getEntityRecords } = select( coreStore );
const { getBlocks } = select( blockEditorStore );
const { comments, blocks } = useSelect(
( select ) => {
const { getEntityRecords } = select( coreStore );
const { getBlocks } = select( blockEditorStore );

return {
comments: getEntityRecords( 'root', 'comment', { post: postId } ),
blocks: getBlocks( clientId ),
};
}, [] );
return {
comments: getEntityRecords( 'root', 'comment', {
post: postId,
per_page: queryPerPage,
} ),
blocks: getBlocks( clientId ),
};
},
[ queryPerPage, postId, clientId ]
);

const blockContexts = useMemo(
() => comments?.map( ( comment ) => ( { commentId: comment.id } ) ),
Expand Down

0 comments on commit 1668cd3

Please sign in to comment.