Skip to content

Commit 94b0493

Browse files
committed
fix: clean the editor store when the moda is close
1 parent 7b0b9c8 commit 94b0493

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

src/editors/containers/EditorContainer/hooks.ts

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export const handleSaveClicked = ({
4040
destination,
4141
dispatch,
4242
returnFunction,
43-
validateEntry,
4443
});
4544
}
4645

src/editors/containers/EditorContainer/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const EditorContainer: React.FC<Props> = ({
9494
const onSave = () => {
9595
setSaved(true);
9696
handleSave();
97+
dispatch({ type: 'resetEditor' });
9798
};
9899
// Stops user from navigating away if they have unsaved changes.
99100
usePromptIfDirty(() => {
@@ -109,6 +110,7 @@ const EditorContainer: React.FC<Props> = ({
109110
openCancelConfirmModal();
110111
} else {
111112
handleCancel();
113+
dispatch({ type: 'resetEditor' });
112114
}
113115
};
114116
return (
@@ -128,6 +130,7 @@ const EditorContainer: React.FC<Props> = ({
128130
if (returnFunction) {
129131
closeCancelConfirmModal();
130132
}
133+
dispatch({ type: 'resetEditor' });
131134
}}
132135
>
133136
<FormattedMessage {...messages.okButtonLabel} />

src/editors/data/redux/index.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,22 @@ import { AdvancedProblemType, ProblemType } from '../constants/problem';
1212

1313
export { default as thunkActions } from './thunkActions';
1414

15-
const rootReducer = combineReducers({
15+
const editorReducer = combineReducers({
1616
app: app.reducer,
1717
requests: requests.reducer,
1818
video: video.reducer,
1919
problem: problem.reducer,
2020
game: game.reducer,
2121
});
2222

23+
const rootReducer = (state: any, action: any) => {
24+
if (action.type === 'resetEditor') {
25+
return editorReducer(undefined, action);
26+
}
27+
28+
return editorReducer(state, action);
29+
};
30+
2331
const actions = StrictDict({
2432
app: app.actions,
2533
requests: requests.actions,

src/editors/data/redux/thunkActions/problem.ts

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export const getDataFromOlx = ({ rawOLX, rawSettings, defaultSettings }) => {
5959
};
6060

6161
export const loadProblem = ({ rawOLX, rawSettings, defaultSettings }) => (dispatch) => {
62-
console.debug(rawOLX);
6362
if (isBlankProblem({ rawOLX })) {
6463
dispatch(actions.problem.setEnableTypeSelection(camelizeKeys(defaultSettings)));
6564
} else {

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
import { v4 as uuid4 } from 'uuid';
12
import { StrictDict, parseLibraryImageData, getLibraryImageAssets } from '../../../utils';
23

34
import { RequestKeys } from '../../constants/requests';
45
import api, { loadImages } from '../../services/cms/api';
56
import { actions as requestsActions } from '../requests';
67
import { selectors as appSelectors } from '../app';
7-
import { v4 as uuid4 } from 'uuid';
8-
98

109
// This 'module' self-import hack enables mocking during tests.
1110
// See src/editors/decisions/0005-internal-editor-testability-decisions.md. The whole approach to how hooks are tested

src/editors/hooks.ts

-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export const createBlock = ({
7171
destination,
7272
dispatch,
7373
returnFunction,
74-
validateEntry,
7574
}) => {
7675
if (!content) {
7776
return;

0 commit comments

Comments
 (0)