mirror of
https://github.com/System-End/site.git
synced 2026-04-19 18:35:12 +00:00
* init * res * git * more raccooooons * - * meta * arc! * eeby * deeby * title * rsvp * yarn * new tab * alt * nav * meta * color magic * img conditional * grants * rsvp link * hs * meta * change domain * Change CTA text on Arcade page * new! * powerups * powerup * ob? * temp fix * rev * gal * faq * launch! * link * Post to both arcadius & airtable! * /arcade * exisiting * width * banner * Add ID to shop section * Move old power hour arcade * Tweak project idea generator prompt * Setup API for new shop inventory * Pull carousel items from new table * Display new carousel items * responsive fix * s * Update thinking lines to be a dino * Generate highlighted items list * sp * page * page * Pull highlighted check from airtable * get outta here racoon * fix? * page * reduce space * enable temporary waitlist * fix error * Don't trigger arcadius * button * responsive * Fix the airtable RSVP * Add link to previous power hour in footer * Randomize shop order * Update announcement copy * Remove unused css * Remove amazon mention * Fix typo * Fix arcade api & accessibility tweaks (#1227) * fix grammar * add alt text * fix arcade api * Add missing wizard orpheus link * Update FAQ copy * Add mockup of shop with new order links * Reorder FAQ * Fix shop costs showing * Include current user balance on shop * Update cards & add modals (#1230) update cards & add modals Co-authored-by: Dillon Barnes <dillonb07dev@gnmail.com> * Fix some react mapping without keys * Hide items from client (#1231) * update cards & add modals * filter items sent to client * fix faq typo --------- Co-authored-by: Dillon Barnes <dillonb07dev@gnmail.com> * Whitelist fields pulled from arcade page * Redact fields on shop page data * style * shop css * add alt text * buy button * ticket * Comment outdated copy * Update index.js * quantity * Experiment with changing the "One hour at a time" section * quantities * q * Add links in Arcade FAQ (#1232) * add links in FAQ * update hack-hour to arcade * Bring back slack invites for arcade * fix css --------- Co-authored-by: belle <bellesee1212@gmail.com> Co-authored-by: Zach Latta <zach@zachlatta.com> Co-authored-by: Jasper Mayone <me@jaspermayone.com> Co-authored-by: Dillon Barnes <gh@dillonb07.studio> Co-authored-by: Dillon Barnes <dillonb07dev@gnmail.com> Co-authored-by: Sam Poder <39828164+sampoder@users.noreply.github.com>
60 lines
No EOL
1.4 KiB
JavaScript
60 lines
No EOL
1.4 KiB
JavaScript
let fetchedDataCache = {}
|
|
|
|
async function pullFromStorage() {
|
|
const ts = parseInt(localStorage.getItem('fetchedDataTimestamp'))
|
|
if (!ts) {
|
|
console.log("No timestamp found in storage")
|
|
return null
|
|
}
|
|
|
|
const now = new Date().getTime()
|
|
const expiration = 1000 * 60 * 5 // 5 min
|
|
const isExpired = now - ts > expiration
|
|
|
|
if (isExpired) {
|
|
console.log("Data in storage is expired")
|
|
return null
|
|
}
|
|
|
|
return JSON.parse(localStorage.getItem('fetchedData'))
|
|
}
|
|
|
|
async function fetchData() {
|
|
return await fetch('/api/arcade/hack-hour/inventory').then(d => d.json())
|
|
}
|
|
|
|
async function setToStorage(data) {
|
|
localStorage.setItem('fetchedData', JSON.stringify(data))
|
|
localStorage.setItem('fetchedDataTimestamp', new Date().getTime())
|
|
}
|
|
|
|
async function fetchedDataLoader() {
|
|
if (Object.keys(fetchedDataCache) > 0) {
|
|
console.log("Found data in cache")
|
|
return fetchedDataCache
|
|
}
|
|
const storage = await pullFromStorage()
|
|
if (storage) {
|
|
console.log("Found parts data in storage")
|
|
return storage
|
|
}
|
|
|
|
const data = await fetchData()
|
|
if (data) {
|
|
console.log("found parts data in fetch")
|
|
setToStorage(data)
|
|
fetchedDataCache = data
|
|
return data
|
|
}
|
|
}
|
|
|
|
let fetchDataJob
|
|
async function fetchedData() {
|
|
if (!fetchDataJob) {
|
|
fetchDataJob = fetchedDataLoader()
|
|
}
|
|
return await fetchDataJob
|
|
}
|
|
|
|
// start loading data as soon as this file loads
|
|
fetchedData() |