From 8baec0bd4bfdbabe677bee19804099e4de2a2aa7 Mon Sep 17 00:00:00 2001 From: Mehak Nasir Date: Thu, 8 Sep 2022 15:18:49 +0500 Subject: [PATCH] fix: add response duplication button fixed --- src/discussions/comments/CommentsView.jsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/discussions/comments/CommentsView.jsx b/src/discussions/comments/CommentsView.jsx index 70ecd792..e1966c97 100644 --- a/src/discussions/comments/CommentsView.jsx +++ b/src/discussions/comments/CommentsView.jsx @@ -46,12 +46,12 @@ function usePostComments(postId, endorsed = null) { page: 1, })); }, [postId]); - return { + return [ comments, hasMorePages, isLoading, handleLoadMoreResponses, - }; + ]; } function DiscussionCommentsView({ @@ -61,15 +61,20 @@ function DiscussionCommentsView({ endorsed, isClosed, }) { - const { + const [ comments, hasMorePages, isLoading, handleLoadMoreResponses, - } = usePostComments(postId, endorsed); + ] = usePostComments(postId, endorsed); + const sortedComments = useMemo(() => orderBy(comments, ['endorsed', 'createdAt'], ['desc', 'desc'])); + const [commentList] = usePostComments(postId, EndorsementStatus.UNENDORSED); + + const showAddResponse = endorsed === EndorsementStatus.ENDORSED ? !commentList.length : true; + return ( <>
@@ -81,7 +86,7 @@ function DiscussionCommentsView({ {sortedComments.map(comment => ( ))} - {!!sortedComments.length && !isClosed + {!!sortedComments.length && !isClosed && showAddResponse && } {hasMorePages && !isLoading && (