From 7260fb0a48c3486e507f79e736b4edf71445f4e7 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Wed, 3 Jun 2026 17:50:38 -0700 Subject: show error if daily is not generated yet --- src/components/Game/index.tsx | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/components/Game/index.tsx b/src/components/Game/index.tsx index 9024b03..3b45329 100644 --- a/src/components/Game/index.tsx +++ b/src/components/Game/index.tsx @@ -20,6 +20,18 @@ interface Props { onPlayAgain?: () => void; } +function getUtcDate() { + return new Date().toISOString().split("T")[0]; +} + +function checkDailyIsGenerated(): boolean { + const CDN_URL = import.meta.env.VITE_CDN_URL; + if (!CDN_URL) return false; + + const date = getUtcDate(); + return !!localStorage.getItem(`${CDN_URL}/${date}.mp3`); +} + export function Game({ guesses, todaysSolution, @@ -31,7 +43,26 @@ export function Game({ mode = "daily", onPlayAgain, }: Props) { - if (didGuess || currentTry === 6) { + const [sessionDate] = React.useState(() => getUtcDate()); + const isGameOver = didGuess || currentTry === 6; + const recentFinishedPlay = localStorage.getItem("recentFinishedPlay"); + const isBlocked = + mode === "daily" && + !!recentFinishedPlay && + new Date(sessionDate) > new Date(recentFinishedPlay) && + !checkDailyIsGenerated(); + + React.useEffect(() => { + if (!isGameOver) return; + + localStorage.setItem("recentFinishedPlay", sessionDate); + }, [isGameOver, sessionDate]); + + if (isBlocked) { + return

Daily MIXX is not available yet. Check back soon!

; + } + + if (isGameOver) { return ( ); } + return ( <> {guesses.map((guess: GuessType, index) => ( @@ -55,7 +87,6 @@ export function Game({ )} -