fix: add response duplication button fixed

This commit is contained in:
Mehak Nasir
2022-09-08 15:18:49 +05:00
committed by Mehak Nasir
parent 93387f1d5b
commit 8baec0bd4b

View File

@@ -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 (
<>
<div className="mx-4 text-primary-700" role="heading" aria-level="2" style={{ lineHeight: '28px' }}>
@@ -81,7 +86,7 @@ function DiscussionCommentsView({
{sortedComments.map(comment => (
<Comment comment={comment} key={comment.id} postType={postType} isClosedPost={isClosed} />
))}
{!!sortedComments.length && !isClosed
{!!sortedComments.length && !isClosed && showAddResponse
&& <ResponseEditor postId={postId} addWrappingDiv />}
{hasMorePages && !isLoading && (
<Button