From 42b7783f476d024e2b479b72870c9b8ba35596c0 Mon Sep 17 00:00:00 2001 From: Dylan Decrulle <81740200+ddecrulle@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:46:09 +0100 Subject: [PATCH] break point --- drama-queen/src/core/usecases/synchronizeData/state.ts | 10 ++++++++-- .../src/core/usecases/synchronizeData/thunks.ts | 6 ++---- .../src/ui/pages/synchronize/SynchronizeData.tsx | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drama-queen/src/core/usecases/synchronizeData/state.ts b/drama-queen/src/core/usecases/synchronizeData/state.ts index bffd9f81..6b509e0f 100644 --- a/drama-queen/src/core/usecases/synchronizeData/state.ts +++ b/drama-queen/src/core/usecases/synchronizeData/state.ts @@ -60,13 +60,19 @@ export const { reducer, actions } = createSlice({ surveyUnitCompleted: 0, }) ), - setDownloadTotalSurveyUnitAndResetSurveyCompleted: ( + updateDownloadTotalSurveyUnit: ( state, { payload }: PayloadAction<{ totalSurveyUnit: number }> ) => { const { totalSurveyUnit } = payload; assert(state.stateDescription === "running" && state.type === "download"); - return { ...state, totalSurveyUnit, surveyCompleted: 0 }; + return { + ...state, + totalSurveyUnit: + state.totalSurveyUnit === Infinity + ? totalSurveyUnit + : state.totalSurveyUnit + totalSurveyUnit, + }; }, downloadSurveyUnitCompleted: (state) => { assert(state.stateDescription === "running" && state.type === "download"); diff --git a/drama-queen/src/core/usecases/synchronizeData/thunks.ts b/drama-queen/src/core/usecases/synchronizeData/thunks.ts index 472a19bd..85ac1324 100644 --- a/drama-queen/src/core/usecases/synchronizeData/thunks.ts +++ b/drama-queen/src/core/usecases/synchronizeData/thunks.ts @@ -42,7 +42,7 @@ export const thunks = { .getSurveyUnitsIdsAndQuestionnaireIdsByCampaign(campaignId) .then((arrayOfIds) => { dispatch( - actions.setDownloadTotalSurveyUnitAndResetSurveyCompleted({ + actions.updateDownloadTotalSurveyUnit({ totalSurveyUnit: arrayOfIds.length, }) ); @@ -51,9 +51,7 @@ export const thunks = { queenApi .getSurveyUnit(id) .then((surveyUnit) => dataStore.updateSurveyUnit(surveyUnit)) - .finally(() => - dispatch(actions.downloadSurveyUnitCompleted()) - ) + .then(() => dispatch(actions.downloadSurveyUnitCompleted())) ) ); }) diff --git a/drama-queen/src/ui/pages/synchronize/SynchronizeData.tsx b/drama-queen/src/ui/pages/synchronize/SynchronizeData.tsx index 7f6c8917..4574a9e3 100644 --- a/drama-queen/src/ui/pages/synchronize/SynchronizeData.tsx +++ b/drama-queen/src/ui/pages/synchronize/SynchronizeData.tsx @@ -21,8 +21,8 @@ export function SynchronizeData() { const { synchronizeData } = useCoreFunctions(); useEffect(() => { - console.log("showProgress", showProgress) - }, [showProgress]); + console.log("surveyUnitProgress", surveyUnitProgress) + }, [surveyUnitProgress]); useEffect( () => {