diff --git a/src/editors/containers/EditorContainer/hooks.ts b/src/editors/containers/EditorContainer/hooks.ts index 0fa1935de..226552486 100644 --- a/src/editors/containers/EditorContainer/hooks.ts +++ b/src/editors/containers/EditorContainer/hooks.ts @@ -1,6 +1,7 @@ import { useState } from 'react'; import { useSelector } from 'react-redux'; +import { Dispatch } from 'redux'; import analyticsEvt from '../../data/constants/analyticsEvt'; import { RequestKeys } from '../../data/constants/requests'; import { selectors } from '../../data/redux'; diff --git a/src/editors/containers/EditorContainer/index.tsx b/src/editors/containers/EditorContainer/index.tsx index eb9e08ab2..7bc04597a 100644 --- a/src/editors/containers/EditorContainer/index.tsx +++ b/src/editors/containers/EditorContainer/index.tsx @@ -94,6 +94,7 @@ const EditorContainer: React.FC = ({ const onSave = () => { setSaved(true); handleSave(); + dispatch({ type: 'resetEditor' }); }; // Stops user from navigating away if they have unsaved changes. usePromptIfDirty(() => { @@ -109,6 +110,7 @@ const EditorContainer: React.FC = ({ openCancelConfirmModal(); } else { handleCancel(); + dispatch({ type: 'resetEditor' }); } }; return ( @@ -128,6 +130,7 @@ const EditorContainer: React.FC = ({ if (returnFunction) { closeCancelConfirmModal(); } + dispatch({ type: 'resetEditor' }); }} > diff --git a/src/editors/data/redux/index.ts b/src/editors/data/redux/index.ts index 775866296..3606f99aa 100644 --- a/src/editors/data/redux/index.ts +++ b/src/editors/data/redux/index.ts @@ -12,7 +12,7 @@ import { AdvancedProblemType, ProblemType } from '../constants/problem'; export { default as thunkActions } from './thunkActions'; -const rootReducer = combineReducers({ +const editorReducer = combineReducers({ app: app.reducer, requests: requests.reducer, video: video.reducer, @@ -20,6 +20,14 @@ const rootReducer = combineReducers({ game: game.reducer, }); +const rootReducer = (state: any, action: any) => { + if (action.type === 'resetEditor') { + return editorReducer(undefined, action); + } + + return editorReducer(state, action); +}; + const actions = StrictDict({ app: app.actions, requests: requests.actions, diff --git a/src/editors/data/redux/thunkActions/problem.ts b/src/editors/data/redux/thunkActions/problem.ts index fce98d273..cd9567d40 100644 --- a/src/editors/data/redux/thunkActions/problem.ts +++ b/src/editors/data/redux/thunkActions/problem.ts @@ -59,7 +59,6 @@ export const getDataFromOlx = ({ rawOLX, rawSettings, defaultSettings }) => { }; export const loadProblem = ({ rawOLX, rawSettings, defaultSettings }) => (dispatch) => { - console.debug(rawOLX); if (isBlankProblem({ rawOLX })) { dispatch(actions.problem.setEnableTypeSelection(camelizeKeys(defaultSettings))); } else { diff --git a/src/editors/data/redux/thunkActions/requests.js b/src/editors/data/redux/thunkActions/requests.js index 084aa45ca..cb0cd60d3 100644 --- a/src/editors/data/redux/thunkActions/requests.js +++ b/src/editors/data/redux/thunkActions/requests.js @@ -1,11 +1,10 @@ +import { v4 as uuid4 } from 'uuid'; import { StrictDict, parseLibraryImageData, getLibraryImageAssets } from '../../../utils'; import { RequestKeys } from '../../constants/requests'; import api, { loadImages } from '../../services/cms/api'; import { actions as requestsActions } from '../requests'; import { selectors as appSelectors } from '../app'; -import { v4 as uuid4 } from 'uuid'; - // This 'module' self-import hack enables mocking during tests. // See src/editors/decisions/0005-internal-editor-testability-decisions.md. The whole approach to how hooks are tested diff --git a/src/editors/hooks.ts b/src/editors/hooks.ts index ef98a2ea6..05d471198 100644 --- a/src/editors/hooks.ts +++ b/src/editors/hooks.ts @@ -71,7 +71,6 @@ export const createBlock = ({ destination, dispatch, returnFunction, - validateEntry, }) => { if (!content) { return;