fix: deleting a post from sidebar renders entire MFE in the sidebar (#403)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user