X-Git-Url: https://git.r.bdr.sh/rbdr/prompt/blobdiff_plain/0931cb4c8774df6d270e0af33e572438a162ae18..HEAD:/src/lib/stores/prompt.js?ds=sidebyside diff --git a/src/lib/stores/prompt.js b/src/lib/stores/prompt.js index 7559657..3284865 100644 --- a/src/lib/stores/prompt.js +++ b/src/lib/stores/prompt.js @@ -2,6 +2,7 @@ import { readable } from 'svelte/store'; import { browser } from '$app/env'; const internals = { + kVersion: '1:', // in case we need to force a re-fetch kHost: import.meta.env.VITE_PUBLIC_BASE_PATH || 'http://localhost:3000', kDataPrefix: '/data/', kAdjectivesPath: '/adjectives.json', @@ -11,14 +12,14 @@ const internals = { const shortLocale = locale.split('-')[0]; const targetFile = internals.kHost + internals.kDataPrefix + shortLocale + path; - const data = browser && sessionStorage.getItem(targetFile); + const data = browser && localStorage.getItem(internals.kVersion + targetFile); if (data) { return JSON.parse(data); } let newData = await (await fetch(targetFile)).json(); - browser && sessionStorage.setItem(targetFile, JSON.stringify(newData)); + browser && localStorage.setItem(internals.kVersion + targetFile, JSON.stringify(newData)); return newData; },