From 7b0b9c8e1dc036be3bb24a4e474c551ae67a422c Mon Sep 17 00:00:00 2001 From: Diana Olarte Date: Tue, 17 Dec 2024 20:13:16 +1100 Subject: [PATCH] refactor: allow open the problem modal when is a new component --- src/editors/containers/ProblemEditor/index.tsx | 6 ++++-- src/editors/data/redux/thunkActions/problem.ts | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/editors/containers/ProblemEditor/index.tsx b/src/editors/containers/ProblemEditor/index.tsx index d8154c7e87..519a87d79b 100644 --- a/src/editors/containers/ProblemEditor/index.tsx +++ b/src/editors/containers/ProblemEditor/index.tsx @@ -65,11 +65,13 @@ const ProblemEditor: React.FC = ({ }; export const mapStateToProps = (state) => ({ - blockFinished: selectors.requests.isFinished(state, { requestKey: RequestKeys.fetchBlock }), + blockFinished: selectors.app.isCreateBlock(state) + || selectors.requests.isFinished(state, { requestKey: RequestKeys.fetchBlock }), blockFailed: selectors.requests.isFailed(state, { requestKey: RequestKeys.fetchBlock }), problemType: selectors.problem.problemType(state), blockValue: selectors.app.blockValue(state), - advancedSettingsFinished: selectors.requests.isFinished(state, { requestKey: RequestKeys.fetchAdvancedSettings }), + advancedSettingsFinished: selectors.app.isCreateBlock(state) + || selectors.requests.isFinished(state, { requestKey: RequestKeys.fetchAdvancedSettings }), }); export const mapDispatchToProps = { diff --git a/src/editors/data/redux/thunkActions/problem.ts b/src/editors/data/redux/thunkActions/problem.ts index 79916195e4..fce98d273e 100644 --- a/src/editors/data/redux/thunkActions/problem.ts +++ b/src/editors/data/redux/thunkActions/problem.ts @@ -59,6 +59,7 @@ 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 { @@ -84,7 +85,7 @@ export const fetchAdvancedSettings = ({ rawOLX, rawSettings }) => (dispatch) => }; export const initializeProblem = (blockValue) => (dispatch, getState) => { - const rawOLX = _.get(blockValue, 'data.data', {}); + const rawOLX = _.get(blockValue, 'data.data', ''); const rawSettings = _.get(blockValue, 'data.metadata', {}); const learningContextId = selectors.app.learningContextId(getState()); if (isLibraryKey(learningContextId)) {