From: Ruben Beltran del Rio Date: Sun, 29 Aug 2021 21:55:21 +0000 (+0200) Subject: Version the corpus X-Git-Url: https://git.r.bdr.sh/rbdr/prompt/commitdiff_plain/5f33c2b50f27233e0e85da021be372b47c22b69d?hp=156fa16e138693f95465caddd0398a8ac5d66441 Version the corpus --- diff --git a/src/lib/stores/prompt.js b/src/lib/stores/prompt.js index d0dc629..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 && localStorage.getItem(targetFile); + const data = browser && localStorage.getItem(internals.kVersion + targetFile); if (data) { return JSON.parse(data); } let newData = await (await fetch(targetFile)).json(); - browser && localStorage.setItem(targetFile, JSON.stringify(newData)); + browser && localStorage.setItem(internals.kVersion + targetFile, JSON.stringify(newData)); return newData; },