- added feature to cache sounds for cross devices - should work in theory

This commit is contained in:
2025-10-29 15:04:40 +00:00
parent cf72a1e1d3
commit a8abed2246
10 changed files with 56 additions and 26 deletions

View File

@@ -1,12 +1,15 @@
export async function getOrCacheBlob(url: string) {
console.log(url);
const cache = await caches.open("app-sounds-v1");
if (cache) console.log(cache);
const hit = await cache.match(url);
if (hit) return await hit.blob();
const res = await fetch(url, { cache: "no-store" });
console.log("fetching...");
if (!res.ok) throw new Error(`Fetch failed: ${res.status}`);
await cache.put(url, res.clone());
await cache.put(url, res.clone());
return await res.blob();
}