From 30afbfb7b81b0ab20bbff4e16df3ea446a1c10ad Mon Sep 17 00:00:00 2001 From: "adeel.tajamul" Date: Thu, 10 Mar 2022 06:50:37 +0500 Subject: [PATCH] fix: posts not loading when scrolled to bottom --- src/discussions/posts/PostsView.jsx | 38 +++++++---------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/src/discussions/posts/PostsView.jsx b/src/discussions/posts/PostsView.jsx index 31fbfd91..f3a57590 100644 --- a/src/discussions/posts/PostsView.jsx +++ b/src/discussions/posts/PostsView.jsx @@ -56,30 +56,7 @@ PostsList.propTypes = { }; PostsList.defaultProps = { - posts: null, -}; - -function AllPostsList() { - const posts = useSelector(selectAllThreads); - return ; -} - -function TopicPostsList({ topicId }) { - const posts = useSelector(selectTopicThreads([topicId])); - return ; -} - -TopicPostsList.propTypes = { - topicId: PropTypes.string.isRequired, -}; - -function CategoryPostsList({ category }) { - const topicIds = useSelector(selectTopicsUnderCategory)(category); - const posts = useSelector(selectTopicThreads(topicIds)); - return ; -} -CategoryPostsList.propTypes = { - category: PropTypes.string.isRequired, + posts: [], }; function PostsView({ showOwnPosts }) { @@ -90,20 +67,23 @@ function PostsView({ showOwnPosts }) { } = useContext(DiscussionContext); const dispatch = useDispatch(); const { authenticatedUser } = useContext(AppContext); - const topicIds = null; + let topicIds = null; const orderBy = useSelector(selectThreadSorting()); const filters = useSelector(selectThreadFilters()); const nextPage = useSelector(selectThreadNextPage()); const loadingStatus = useSelector(threadsLoadingStatus()); let postsListComponent = null; + let posts = []; if (topicId) { - postsListComponent = ; + posts = useSelector(selectTopicThreads([topicId])); } else if (category) { - postsListComponent = ; + topicIds = useSelector(selectTopicsUnderCategory)(category); + posts = useSelector(selectTopicThreads(topicIds)); } else { - postsListComponent = ; + posts = useSelector(selectAllThreads); } + postsListComponent = ; useEffect(() => { // The courseId from the URL is the course we WANT to load. dispatch(fetchThreads(courseId, { @@ -122,7 +102,7 @@ function PostsView({ showOwnPosts }) { filters, page: nextPage, author: showOwnPosts ? authenticatedUser.username : null, - }, postsListComponent)); + }, posts)); } };