diff --git a/src/discussions/posts/data/slices.js b/src/discussions/posts/data/slices.js index 8d3c5a55..754dfa3d 100644 --- a/src/discussions/posts/data/slices.js +++ b/src/discussions/posts/data/slices.js @@ -1,5 +1,6 @@ /* eslint-disable no-param-reassign,import/prefer-default-export */ import { createSlice } from '@reduxjs/toolkit'; +import omitBy from 'lodash/omitBy'; import { PostsStatusFilter, RequestStatus, ThreadOrdering, ThreadType, @@ -175,7 +176,7 @@ const threadsSlice = createSlice({ state.postStatus = RequestStatus.SUCCESSFUL; state.threadsInTopic[topicId] = state.threadsInTopic[topicId].filter(item => item !== threadId); state.pages = state.pages.map(page => page?.filter(item => item !== threadId)); - delete state.threadsById[threadId]; + state.threadsById = omitBy(state.threadsById, (thread) => thread.id === threadId); }, deleteThreadFailed: (state) => { state.postStatus = RequestStatus.FAILED; diff --git a/src/discussions/posts/post/Post.jsx b/src/discussions/posts/post/Post.jsx index 7cf2159c..2312697d 100644 --- a/src/discussions/posts/post/Post.jsx +++ b/src/discussions/posts/post/Post.jsx @@ -30,6 +30,7 @@ function Post({ const location = useLocation(); const history = useHistory(); const dispatch = useDispatch(); + const { enableInContextSidebar } = useContext(DiscussionContext); const { courseId } = useSelector((state) => state.courseTabs); const topic = useSelector(selectTopic(post.topicId)); const getTopicSubsection = useSelector(selectorForUnitSubsection); @@ -49,7 +50,10 @@ function Post({ const handleDeleteConfirmation = () => { dispatch(removeThread(post.id)); - history.push('.'); + history.push({ + pathname: '.', + search: enableInContextSidebar && '?inContextSidebar', + }); hideDeleteConfirmation(); }; @@ -58,7 +62,6 @@ function Post({ hideReportConfirmation(); }; - const { enableInContextSidebar } = useContext(DiscussionContext); const actionHandlers = { [ContentActions.EDIT_CONTENT]: () => history.push({ ...location,