@data-fair/lib-vue 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/session.js +6 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-vue",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "Composables and other utilities for Vue applications in the data-fair stack.",
5
5
  "main": "index.js",
6
6
  "files": [
package/session.js CHANGED
@@ -37,6 +37,10 @@ const goTo = (url) => {
37
37
  }
38
38
  if (url) { topLocation.href = url } else { topLocation.reload() }
39
39
  }
40
+ const getSiteInfoStorage = (sitePath) => {
41
+ const siteInfoStorageStr = window.localStorage.getItem('sd-site-info' + sitePath)
42
+ return siteInfoStorageStr ? JSON.parse(siteInfoStorageStr) : null
43
+ }
40
44
  const defaultOptions = { directoryUrl: '/simple-directory', sitePath: '', defaultLang: 'fr' }
41
45
  export async function getSession (initOptions) {
42
46
  const options = { ...defaultOptions, ...initOptions }
@@ -110,7 +114,7 @@ export async function getSession (initOptions) {
110
114
  state.accountRole = 'admin'
111
115
  }
112
116
  if (!ssr) {
113
- const siteInfoStorage = getSiteInfoStorage()
117
+ const siteInfoStorage = getSiteInfoStorage(options.sitePath)
114
118
  site.value = siteInfoStorage ? siteInfoStorage.info : null
115
119
  }
116
120
  }
@@ -218,10 +222,6 @@ export async function getSession (initOptions) {
218
222
  await customFetch(`${options.directoryUrl}/api/auth/keepalive`, { method: 'POST' })
219
223
  readState()
220
224
  }
221
- const getSiteInfoStorage = () => {
222
- const siteInfoStorageStr = window.localStorage.getItem('sd-site-info' + options.sitePath)
223
- return siteInfoStorageStr ? JSON.parse(siteInfoStorageStr) : null
224
- }
225
225
  const setSiteInfoStorage = (siteInfo) => {
226
226
  const siteInfoStorage = { info: siteInfo, updatedAt: new Date().getTime() }
227
227
  window.localStorage.setItem('sd-site-info' + options.sitePath, JSON.stringify(siteInfoStorage))
@@ -242,7 +242,7 @@ export async function getSession (initOptions) {
242
242
  await keepalive()
243
243
  }
244
244
  if (options.siteInfo) {
245
- const lastSiteInfoStorage = getSiteInfoStorage()
245
+ const lastSiteInfoStorage = getSiteInfoStorage(options.sitePath)
246
246
  if (!lastSiteInfoStorage || (new Date().getTime() - Number(lastSiteInfoStorage.updatedAt)) > 10000) {
247
247
  await refreshSiteInfo()
248
248
  }