Skip to content

Commit

Permalink
feat: delete external resources for not needed questionnaires
Browse files Browse the repository at this point in the history
  • Loading branch information
QRuhier committed Oct 11, 2024
1 parent bbf4c69 commit d6f997f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions drama-queen/src/core/usecases/synchronizeData/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,11 @@ export const thunks = {
const externalQuestionnaires =
await getExternalQuestionnaires(externalResourcesUrl)

const { neededQuestionnaires } = getExternalQuestionnaireFiltered(
questionnaireIdInSuccess,
externalQuestionnaires
)
const { neededQuestionnaires, notNeededQuestionnaires } =
getExternalQuestionnaireFiltered(
questionnaireIdInSuccess,
externalQuestionnaires
)

// add in cache the missing external resources for needed questionnaires
await Promise.all(
Expand All @@ -203,6 +204,13 @@ export const thunks = {
)
)
)

// delete the cache of every not needed questionnaire
await Promise.all(
notNeededQuestionnaires.map((questionnaire) =>
caches.delete(questionnaire.cacheName)
)
)
}

//We await untill all the promises are finished
Expand Down

0 comments on commit d6f997f

Please sign in to comment.