Skip to content

Commit 7ece69c

Browse files
committed
fix: avoid page reload after an xblock edition
1 parent ad62519 commit 7ece69c

File tree

3 files changed

+1
-33
lines changed

3 files changed

+1
-33
lines changed

src/course-unit/hooks.jsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -213,24 +213,6 @@ export const useCourseUnit = ({ courseId, blockId }) => {
213213
}
214214
}, [isMoveModalOpen]);
215215

216-
useEffect(() => {
217-
const handlePageRefreshUsingStorage = (event) => {
218-
// ignoring tests for if block, because it triggers when someone
219-
// edits the component using editor which has a separate store
220-
/* istanbul ignore next */
221-
if (event.key === 'courseRefreshTriggerOnComponentEditSave') {
222-
dispatch(fetchCourseSectionVerticalData(blockId, sequenceId));
223-
dispatch(fetchCourseVerticalChildrenData(blockId, isSplitTestType));
224-
localStorage.removeItem(event.key);
225-
}
226-
};
227-
228-
window.addEventListener('storage', handlePageRefreshUsingStorage);
229-
return () => {
230-
window.removeEventListener('storage', handlePageRefreshUsingStorage);
231-
};
232-
}, [blockId, sequenceId, isSplitTestType]);
233-
234216
return {
235217
sequenceId,
236218
courseUnit,

src/editors/data/redux/thunkActions/app.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,6 @@ export const saveBlock = (content, returnToUnit) => (dispatch) => {
125125
content,
126126
onSuccess: (response) => {
127127
dispatch(actions.app.setSaveResponse(response));
128-
const parsedData = JSON.parse(response.config.data);
129-
if (parsedData?.has_changes) {
130-
const storageKey = 'courseRefreshTriggerOnComponentEditSave';
131-
localStorage.setItem(storageKey, Date.now());
132-
133-
window.dispatchEvent(new StorageEvent('storage', {
134-
key: storageKey,
135-
newValue: Date.now().toString(),
136-
}));
137-
}
138128
returnToUnit(response.data);
139129
},
140130
}));

src/editors/data/redux/thunkActions/app.test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,7 @@ describe('app thunkActions', () => {
352352
});
353353
it('dispatches actions.app.setSaveResponse with response and then calls returnToUnit', () => {
354354
dispatch.mockClear();
355-
const mockParsedData = { has_changes: true };
356-
const response = {
357-
config: { data: JSON.stringify(mockParsedData) },
358-
data: {},
359-
};
355+
const response = 'testRESPONSE';
360356
calls[1][0].saveBlock.onSuccess(response);
361357
expect(dispatch).toHaveBeenCalledWith(actions.app.setSaveResponse(response));
362358
expect(returnToUnit).toHaveBeenCalled();

0 commit comments

Comments
 (0)