diff --git a/dashboard/src/components/DataLoader.js b/dashboard/src/components/DataLoader.js index 560b94c43..449ffb589 100644 --- a/dashboard/src/components/DataLoader.js +++ b/dashboard/src/components/DataLoader.js @@ -105,7 +105,6 @@ export default function DataLoader() { const shouldStop = progress !== null && total !== null && isLoading; if (shouldStart) { - console.log('START FUCKING SHIT initialLoad', initialLoad); Promise.resolve() .then(async () => { /* @@ -123,18 +122,6 @@ export default function DataLoader() { .then(() => (initialLoad ? migrateData() : Promise.resolve())) .then(() => getCacheItem(dashboardCurrentCacheKey)) .then((lastLoadValue) => { - console.log('lastLoadValue', lastLoadValue); - console.log('initialLoad', initialLoad); - console.log({ - path: '/organisation/stats', - query: { - organisation: organisationId, - after: lastLoadValue || 0, - withDeleted: true, - // Medical data is never saved in cache so we always have to download all at every page reload. - withAllMedicalData: initialLoad, - }, - }); setLastLoad(lastLoadValue || 0); API.get({ path: '/organisation/stats', @@ -146,7 +133,6 @@ export default function DataLoader() { withAllMedicalData: initialLoad, }, }).then(({ data: stats }) => { - console.log('REFRESH stats', stats); if (!stats) return; const newList = []; let itemsCount = @@ -407,7 +393,7 @@ export default function DataLoader() { async function resetLoaderOnError() { // an error was thrown, the data was not downloaded, // this can result in data corruption, we need to reset the loader - await clearCache('resetLoaderOnError'); + await clearCache(); setLastLoad(0); toast.error('Désolé, une erreur est survenue lors du chargement de vos données, veuillez réessayer', { onClose: () => window.location.replace('/auth'), @@ -565,7 +551,7 @@ export default function DataLoader() { .then(async () => { console.log('cacheIsInvalidated', cacheIsInvalidated); if (cacheIsInvalidated) { - await clearCache('cacheIsInvalidated').then(() => { + await clearCache().then(() => { // startInitialLoad setLastLoad(0); setIsLoading(true); @@ -639,8 +625,8 @@ export function useDataLoader(options = { refreshOnMount: false }) { setLoadingText('Chargement des données'); } - async function resetCache(from) { - await clearCache('resetCache' + (from ? ` from ${from}` : '')); + async function resetCache() { + await clearCache(); setLastLoad(0); } diff --git a/dashboard/src/components/ReceptionService.js b/dashboard/src/components/ReceptionService.js index e5b9e5d46..b0518f68d 100644 --- a/dashboard/src/components/ReceptionService.js +++ b/dashboard/src/components/ReceptionService.js @@ -15,9 +15,11 @@ const ReceptionService = ({ report, team, dateString, dataTestIdPrefix = '', ser useEffect( // Init services for a team. We need to fetch services from legacy report and database and merge them. function initServices() { + console.log('INIT SERVICE FROM ReceptionService ?'); if (!dateString || !team?._id || dateString === 'undefined') { return capture('Missing params for initServices in reception', { extra: { dateString, team, report } }); } + console.log('INIT SERVICE FROM ReceptionService '); API.get({ path: `/service/team/${team._id}/date/${dateString}` }).then((res) => { if (!res.ok) return toast.error(); const servicesFromLegacyReport = report?.services?.length ? JSON.parse(report?.services) : {}; diff --git a/dashboard/src/scenes/auth/signin.js b/dashboard/src/scenes/auth/signin.js index ceb2fc6d8..e361aa867 100644 --- a/dashboard/src/scenes/auth/signin.js +++ b/dashboard/src/scenes/auth/signin.js @@ -64,7 +64,7 @@ const SignIn = () => { setAuthViaCookie(true); const { organisation } = user; if (organisation._id !== window.localStorage.getItem('mano-organisationId')) { - await resetCache('reset cache from different organisation'); + await resetCache(); } window.localStorage.setItem('mano-organisationId', organisation._id); setOrganisation(organisation); @@ -112,7 +112,7 @@ const SignIn = () => { if (token) setToken(token); setSessionInitialTimestamp(Date.now()); if (organisation._id !== window.localStorage.getItem('mano-organisationId')) { - await resetCache('reset cache from different organisation too'); + await resetCache(); } window.localStorage.setItem('mano-organisationId', organisation._id); setOrganisation(organisation); diff --git a/dashboard/src/services/dataManagement.js b/dashboard/src/services/dataManagement.js index febc19d75..f104bb168 100644 --- a/dashboard/src/services/dataManagement.js +++ b/dashboard/src/services/dataManagement.js @@ -52,8 +52,7 @@ async function getManoCacheStorage() { return manoCacheStorage; } -export async function clearCache(calledFrom) { - console.log('clearCache called from', calledFrom); +export async function clearCache() { (await getManoCacheStorage())?.clear(); manoCacheStorage = undefined; // needed so that the clean the all DB when required functions window.localStorage?.clear();