@data-fair/lib-vue 1.9.3 → 1.9.4

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 +1 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@data-fair/lib-vue",
3
- "version": "1.9.3",
3
+ "version": "1.9.4",
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,10 +37,6 @@ 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
- }
44
40
  const defaultOptions = { directoryUrl: '/simple-directory', sitePath: '', defaultLang: 'fr' }
45
41
  export async function getSession (initOptions) {
46
42
  const options = { ...defaultOptions, ...initOptions }
@@ -113,10 +109,6 @@ export async function getSession (initOptions) {
113
109
  }
114
110
  state.accountRole = 'admin'
115
111
  }
116
- if (!ssr) {
117
- const siteInfoStorage = getSiteInfoStorage(options.sitePath)
118
- site.value = siteInfoStorage ? siteInfoStorage.info : null
119
- }
120
112
  }
121
113
  readState()
122
114
  debug('initial state', state)
@@ -222,17 +214,11 @@ export async function getSession (initOptions) {
222
214
  await customFetch(`${options.directoryUrl}/api/auth/keepalive`, { method: 'POST' })
223
215
  readState()
224
216
  }
225
- const setSiteInfoStorage = (siteInfo) => {
226
- const siteInfoStorage = { info: siteInfo, updatedAt: new Date().getTime() }
227
- window.localStorage.setItem('sd-site-info' + options.sitePath, JSON.stringify(siteInfoStorage))
228
- }
229
217
  const refreshSiteInfo = async () => {
230
218
  const siteInfo = await customFetch(`${options.directoryUrl}/api/sites/_public`) ?? null
231
219
  site.value = siteInfo
232
- if (!ssr) {
233
- setSiteInfoStorage(siteInfo)
234
- }
235
220
  }
221
+ if (options.siteInfo) { await refreshSiteInfo() }
236
222
  // immediately performs a keepalive, but only on top windows (not iframes or popups)
237
223
  // and only if it was not done very recently (maybe from a refreshed page next to this one)
238
224
  // also run an auto-refresh loop
@@ -241,12 +227,6 @@ export async function getSession (initOptions) {
241
227
  if (state.user && (!lastKeepalive || (new Date().getTime() - Number(lastKeepalive)) > 10000)) {
242
228
  await keepalive()
243
229
  }
244
- if (options.siteInfo) {
245
- const lastSiteInfoStorage = getSiteInfoStorage(options.sitePath)
246
- if (!lastSiteInfoStorage || (new Date().getTime() - Number(lastSiteInfoStorage.updatedAt)) > 10000) {
247
- await refreshSiteInfo()
248
- }
249
- }
250
230
  const refreshLoopDelay = 10 * 60 * 1000 // 10 minutes
251
231
  setInterval(() => {
252
232
  const lastKeepalive = window.localStorage.getItem('sd-keepalive' + options.sitePath)