From a3eb518dcccaebd0f48c708c189ad2fcb07f0f73 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sun, 21 Aug 2022 13:50:18 +0200 Subject: fix(comments): load all comments on a post Previously, only the first 10 comments was loaded. So I update the fetching method to retrieve all the comments on a post. Also, I choose to order comments on client side because of a bug with WPGraphQL. Finally, I renamed the Comment type to SingleComment to avoid conflict with existing types. --- src/components/organisms/layout/comments-list.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/components/organisms/layout/comments-list.tsx') diff --git a/src/components/organisms/layout/comments-list.tsx b/src/components/organisms/layout/comments-list.tsx index 97eccb7..deb0776 100644 --- a/src/components/organisms/layout/comments-list.tsx +++ b/src/components/organisms/layout/comments-list.tsx @@ -1,7 +1,7 @@ -import SingleComment, { +import Comment, { type CommentProps, } from '@components/organisms/layout/comment'; -import { Comment } from '@ts/types/app'; +import { SingleComment } from '@ts/types/app'; import { FC } from 'react'; import styles from './comments-list.module.scss'; @@ -9,7 +9,7 @@ export type CommentsListProps = Pick & { /** * An array of comments. */ - comments: Comment[]; + comments: SingleComment[]; /** * The maximum depth. Use `0` to not display nested comments. */ @@ -30,18 +30,18 @@ const CommentsList: FC = ({ /** * Get each comment wrapped in a list item. * - * @param {Comment[]} commentsList - An array of comments. + * @param {SingleComment[]} commentsList - An array of comments. * @returns {JSX.Element[]} The list items. */ const getItems = ( - commentsList: Comment[], + commentsList: SingleComment[], startLevel: number ): JSX.Element[] => { const isLastLevel = startLevel === depth; return commentsList.map(({ replies, ...comment }) => (
  • -