From 44597c5e57164806b544187153f8f52a8ae3ac50 Mon Sep 17 00:00:00 2001 From: Apeksha Bhosale <7846888+ApekshaBhosale@users.noreply.github.com> Date: Fri, 18 Feb 2022 19:28:11 +0530 Subject: [PATCH] fix: marking old async functions as async in the backed for settings (#10723) --- app/client/src/actions/evaluationActions.ts | 3 +- .../src/constants/ReduxActionConstants.tsx | 1 + app/client/src/sagas/InitSagas.ts | 42 ++++++++++++------- app/client/src/utils/JSPaneUtils.tsx | 5 ++- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/app/client/src/actions/evaluationActions.ts b/app/client/src/actions/evaluationActions.ts index e711d904ec..344c9997db 100644 --- a/app/client/src/actions/evaluationActions.ts +++ b/app/client/src/actions/evaluationActions.ts @@ -17,7 +17,7 @@ export const FIRST_EVAL_REDUX_ACTIONS = [ export const EVALUATE_REDUX_ACTIONS = [ ...FIRST_EVAL_REDUX_ACTIONS, // Actions - ReduxActionTypes.FETCH_ACTIONS_SUCCESS, + ReduxActionTypes.FETCH_PLUGIN_AND_JS_ACTIONS_SUCCESS, ReduxActionTypes.FETCH_PLUGIN_FORM_CONFIGS_SUCCESS, ReduxActionTypes.FETCH_ACTIONS_VIEW_MODE_SUCCESS, ReduxActionErrorTypes.FETCH_ACTIONS_ERROR, @@ -35,7 +35,6 @@ export const EVALUATE_REDUX_ACTIONS = [ ReduxActionErrorTypes.EXECUTE_PLUGIN_ACTION_ERROR, ReduxActionTypes.CLEAR_ACTION_RESPONSE, // JS Actions - ReduxActionTypes.FETCH_JS_ACTIONS_SUCCESS, ReduxActionTypes.CREATE_JS_ACTION_SUCCESS, ReduxActionErrorTypes.FETCH_JS_ACTIONS_ERROR, ReduxActionTypes.DELETE_JS_ACTION_SUCCESS, diff --git a/app/client/src/constants/ReduxActionConstants.tsx b/app/client/src/constants/ReduxActionConstants.tsx index 34b2429448..2ce3fd54da 100644 --- a/app/client/src/constants/ReduxActionConstants.tsx +++ b/app/client/src/constants/ReduxActionConstants.tsx @@ -645,6 +645,7 @@ export const ReduxActionTypes = { /* This action constants is for identifying the status of the updates of the entities */ ENTITY_UPDATE_STARTED: "ENTITY_UPDATE_STARTED", ENTITY_UPDATE_SUCCESS: "ENTITY_UPDATE_SUCCESS", + FETCH_PLUGIN_AND_JS_ACTIONS_SUCCESS: "FETCH_PLUGIN_AND_JS_ACTIONS_SUCCESS", }; export type ReduxActionType = typeof ReduxActionTypes[keyof typeof ReduxActionTypes]; diff --git a/app/client/src/sagas/InitSagas.ts b/app/client/src/sagas/InitSagas.ts index 36eb1980be..8c176dfba0 100644 --- a/app/client/src/sagas/InitSagas.ts +++ b/app/client/src/sagas/InitSagas.ts @@ -126,7 +126,6 @@ function* initializeEditorSaga( }), fetchPageList({ applicationId }, APP_MODE.EDIT), ]; - const successEffects = [ ReduxActionTypes.FETCH_APPLICATION_SUCCESS, ReduxActionTypes.FETCH_PAGE_LIST_SUCCESS, @@ -136,12 +135,6 @@ function* initializeEditorSaga( ReduxActionErrorTypes.FETCH_APPLICATION_ERROR, ReduxActionErrorTypes.FETCH_PAGE_LIST_ERROR, ]; - const jsActionsCall = yield failFastApiCalls( - [fetchJSCollections({ applicationId })], - [ReduxActionTypes.FETCH_JS_ACTIONS_SUCCESS], - [ReduxActionErrorTypes.FETCH_JS_ACTIONS_ERROR], - ); - if (!jsActionsCall) return; if (pageId) { initCalls.push(fetchPage(pageId, true) as any); successEffects.push(ReduxActionTypes.FETCH_PAGE_SUCCESS); @@ -156,6 +149,34 @@ function* initializeEditorSaga( if (!applicationAndLayoutCalls) return; + const initActionsCalls = [ + fetchActions({ applicationId }, []), + fetchJSCollections({ applicationId }), + ]; + + const successActionEffects = [ + ReduxActionTypes.FETCH_JS_ACTIONS_SUCCESS, + ReduxActionTypes.FETCH_ACTIONS_SUCCESS, + ]; + const failureActionEffects = [ + ReduxActionErrorTypes.FETCH_JS_ACTIONS_ERROR, + ReduxActionErrorTypes.FETCH_ACTIONS_ERROR, + ]; + const allActionCalls = yield failFastApiCalls( + initActionsCalls, + successActionEffects, + failureActionEffects, + ); + + if (!allActionCalls) { + return; + } else { + yield put({ + type: ReduxActionTypes.FETCH_PLUGIN_AND_JS_ACTIONS_SUCCESS, + }); + yield put(executePageLoadActions()); + } + let fetchPageCallResult; const defaultPageId = yield select(getDefaultPageId); const toLoadPageId = pageId || defaultPageId; @@ -193,13 +214,6 @@ function* initializeEditorSaga( ); if (!pluginFormCall) return; - const actionsCall = yield failFastApiCalls( - [fetchActions({ applicationId }, [executePageLoadActions()])], - [ReduxActionTypes.FETCH_ACTIONS_SUCCESS], - [ReduxActionErrorTypes.FETCH_ACTIONS_ERROR], - ); - if (!actionsCall) return; - const currentApplication = yield select(getCurrentApplication); const appName = currentApplication ? currentApplication.name : ""; const appId = currentApplication ? currentApplication.id : ""; diff --git a/app/client/src/utils/JSPaneUtils.tsx b/app/client/src/utils/JSPaneUtils.tsx index 5ecc521f67..1572a757ba 100644 --- a/app/client/src/utils/JSPaneUtils.tsx +++ b/app/client/src/utils/JSPaneUtils.tsx @@ -37,7 +37,10 @@ export const getDifferenceInJSCollection = ( const action = parsedBody.actions[i]; const preExisted = jsAction.actions.find((js) => js.name === action.name); if (preExisted) { - if (preExisted.actionConfiguration.body !== action.body) { + if ( + preExisted.actionConfiguration.body !== action.body || + preExisted.actionConfiguration.isAsync !== action.isAsync + ) { toBeUpdatedActions.push({ ...preExisted, actionConfiguration: {