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));
}
};