Testing in progress ;)

This commit is contained in:
Frank Schwenk
2026-06-09 21:43:29 +02:00
parent 5b7706bd6b
commit 66fa24872d
2 changed files with 18 additions and 6 deletions
+16 -4
View File
@@ -89,11 +89,23 @@ async function handleSnooze(slotId, minutes) {
}
}
const ROAST_CACHE_KEY = "medis-roast-day";
async function loadRoast(day) {
try {
const cached = JSON.parse(sessionStorage.getItem(ROAST_CACHE_KEY) || "null");
if (cached?.day === day && cached?.text) return cached;
const roast = await api.roast();
sessionStorage.setItem(ROAST_CACHE_KEY, JSON.stringify({ day: roast.day, text: roast.text }));
return roast;
} catch {
return { text: "Dein Gebrain wartet auf Koffein und Medis." };
}
}
async function refreshDashboard(stats) {
const [today, roast] = await Promise.all([
api.today(),
api.roast().catch(() => ({ text: "Dein Gebrain wartet auf Koffein und Medis." })),
]);
const today = await api.today();
const roast = await loadRoast(today.day);
renderSlots(today.slots, handleTake, handleSnooze);
document.getElementById("roastText").textContent = roast.text;