From 211323b2b510831971eb4a47f6cd2c1e290d9973 Mon Sep 17 00:00:00 2001 From: Muhammad Adeel Tajamul <77053848+muhammadadeeltajamul@users.noreply.github.com> Date: Fri, 30 Sep 2022 16:51:20 +0500 Subject: [PATCH] fix: removed responses sort from frontend (#307) Co-authored-by: adeel.tajamul --- src/discussions/comments/CommentsView.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/discussions/comments/CommentsView.jsx b/src/discussions/comments/CommentsView.jsx index 70ecd792..11e7ad3e 100644 --- a/src/discussions/comments/CommentsView.jsx +++ b/src/discussions/comments/CommentsView.jsx @@ -1,7 +1,6 @@ import React, { useEffect, useMemo } from 'react'; import PropTypes from 'prop-types'; -import { orderBy } from 'lodash'; import { useDispatch, useSelector } from 'react-redux'; import { useParams } from 'react-router'; @@ -13,6 +12,7 @@ import { useDispatchWithState } from '../../data/hooks'; import { Post } from '../posts'; import { selectThread } from '../posts/data/selectors'; import { fetchThread, markThreadAsRead } from '../posts/data/thunks'; +import { filterPosts } from '../utils'; import { selectThreadComments, selectThreadCurrentPage, selectThreadHasMorePages } from './data/selectors'; import { fetchThreadComments } from './data/thunks'; import { Comment, ResponseEditor } from './comment'; @@ -67,9 +67,8 @@ function DiscussionCommentsView({ isLoading, handleLoadMoreResponses, } = usePostComments(postId, endorsed); - const sortedComments = useMemo(() => orderBy(comments, ['endorsed', 'createdAt'], - ['desc', 'desc'])); - + const sortedComments = useMemo(() => [...filterPosts(comments, 'endorsed'), + ...filterPosts(comments, 'unendorsed')], [comments]); return ( <>