From 9f0e48f91482a3fad35170ac8b76dc2d6f9ed785 Mon Sep 17 00:00:00 2001 From: Loup Theron Date: Tue, 3 Oct 2023 17:33:04 +0200 Subject: [PATCH] Add SetTimeout to send the update after the reset --- .../layer/regulation/createOrUpdateRegulation.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/src/domain/use_cases/layer/regulation/createOrUpdateRegulation.ts b/frontend/src/domain/use_cases/layer/regulation/createOrUpdateRegulation.ts index 252fd3773a..5df7f82073 100644 --- a/frontend/src/domain/use_cases/layer/regulation/createOrUpdateRegulation.ts +++ b/frontend/src/domain/use_cases/layer/regulation/createOrUpdateRegulation.ts @@ -22,6 +22,19 @@ export const createOrUpdateRegulation = (processingRegulation, id, previousId) = * /!\ This constraint is only applied to the local (CROSS) regulations table. */ await dispatch(resetPreviousRegulation(previousId, id)) + + /** + * We must wait for the reset to be done. + * TODO Add the two UPDATE into the same transaction to remove this `setTimeout` + */ + setTimeout(() => { + /** + * Then, we update the new regulation with the values of the previous one + */ + dispatch(updateRegulation(feature, REGULATION_ACTION_TYPE.UPDATE)) + }, 1000) + + return } /**