Skip to content

Commit

Permalink
feat: delete external resources root-cache if no external questionnai…
Browse files Browse the repository at this point in the history
…re needed
  • Loading branch information
QRuhier committed Oct 11, 2024
1 parent d6f997f commit 57748de
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drama-queen/src/core/usecases/synchronizeData/thunks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from 'core/tools/externalResources'

const externalResourcesUrl = import.meta.env.VITE_EXTERNAL_RESOURCES_URL
const externalResourcesRootCacheName = 'cache-root-external'

export const thunks = {
download:
Expand Down Expand Up @@ -205,12 +206,17 @@ export const thunks = {
)
)

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

// delete the root-cache of external resources if no external questionnaire is needed
if (neededQuestionnaires.length === 0) {
await caches.delete(externalResourcesRootCacheName)
}
}

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

0 comments on commit 57748de

Please sign in to comment.