Skip to content

Commit

Permalink
Add loading actions to update and refactor js action sagas
Browse files Browse the repository at this point in the history
  • Loading branch information
dvj1988 committed Jun 11, 2024
1 parent 54f8220 commit e75d21b
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions app/client/src/sagas/JSPaneSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,23 +295,11 @@ export function* makeUpdateJSCollection(
) {
const jsUpdates: Record<string, JSUpdate> = action.payload || {};

yield all(
Object.keys(jsUpdates).map((key) =>
put(jsSaveActionStart({ id: jsUpdates[key].id })),
),
);

yield all(
Object.keys(jsUpdates).map((key) =>
call(handleEachUpdateJSCollection, jsUpdates[key]),
),
);

yield all(
Object.keys(jsUpdates).map((key) =>
put(jsSaveActionComplete({ id: jsUpdates[key].id })),
),
);
}

function* updateJSCollection(data: {
Expand All @@ -328,6 +316,7 @@ function* updateJSCollection(data: {
try {
const { deletedActions, jsCollection, newActions } = data;
if (jsCollection) {
yield put(jsSaveActionStart({ id: jsCollection.id }));
const response: JSCollectionCreateUpdateResponse = yield call(
updateJSCollectionAPICall,
jsCollection,
Expand Down Expand Up @@ -367,6 +356,8 @@ function* updateJSCollection(data: {
type: ReduxActionErrorTypes.UPDATE_JS_ACTION_ERROR,
payload: { error, data: jsAction },
});
} finally {
yield put(jsSaveActionComplete({ id: data.jsCollection.id }));
}
}

Expand Down Expand Up @@ -661,6 +652,7 @@ function* handleRefactorJSActionNameSaga(
};
// call to refactor action
try {
yield put(jsSaveActionStart({ id: actionCollection.id }));
const refactorResponse: ApiResponse =
yield JSActionAPI.updateJSCollectionActionRefactor(requestData);

Expand Down Expand Up @@ -688,6 +680,8 @@ function* handleRefactorJSActionNameSaga(
type: ReduxActionErrorTypes.REFACTOR_JS_ACTION_NAME_ERROR,
payload: { collectionId: actionCollection.id },
});
} finally {
yield put(jsSaveActionComplete({ id: actionCollection.id }));
}
}

Expand Down

0 comments on commit e75d21b

Please sign in to comment.