Sfoglia il codice sorgente

no profile force-refresh on client side

Olivier Massot 2 anni fa
parent
commit
6b016cad13

+ 4 - 1
components/Layout/SubHeader/ActivityYear.vue

@@ -63,7 +63,10 @@ const setActivityYear = async (event: string) => {
 
   pageStore.loading = true
   await em.patch(Access, accessProfileStore.currentAccessId, { activityYear: activityYear })
-  await em.refreshProfile()
+  if (process.server) {
+      // Force profile refresh server side to avoid a bug where server and client stores diverge on profile refresh
+      await em.refreshProfile()
+  }
 
   window.location.reload()
 }

+ 5 - 5
components/Layout/SubHeader/DataTiming.vue

@@ -68,11 +68,11 @@ const onUpdate = async (newValue: Array<string>) => {
   setDirty(false)
   pageStore.loading = true
 
-  await em.patch(
-      Access,
-      accessProfileStore.id,
-      {'historical': accessProfileStore.historical}
-  )
+  await em.patch(Access, accessProfileStore.id, {'historical': accessProfileStore.historical})
+  if (process.server) {
+      // Force profile refresh server side to avoid a bug where server and client stores diverge on profile refresh
+      await em.refreshProfile()
+  }
 
   window.location.reload()
 }

+ 5 - 5
components/Layout/SubHeader/DataTimingRange.vue

@@ -51,11 +51,11 @@ const updateDateTimeRange = async (dates: Array<Date>): Promise<any> => {
   setDirty(false)
   pageStore.loading = true
 
-  await em.patch(
-      Access,
-      accessProfileStore.id,
-      {'historical': accessProfileStore.historical}
-  )
+  await em.patch(Access, accessProfileStore.id, {'historical': accessProfileStore.historical})
+  if (process.server) {
+      // Force profile refresh server side to avoid a bug where server and client stores diverge on profile refresh
+      await em.refreshProfile()
+  }
 
   window.location.reload()
 }