aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-06-03 17:50:38 -0700
committerPinapelz <yukais@pinapelz.com>2026-06-03 17:50:38 -0700
commit7260fb0a48c3486e507f79e736b4edf71445f4e7 (patch)
treea6d6c8efbba0e864aa09d033fb761c8e661fb758
parent14172f9dd64ce91ba5cf51f82c53deb6a81d68a6 (diff)
show error if daily is not generated yet
-rw-r--r--src/components/Game/index.tsx35
1 files changed, 33 insertions, 2 deletions
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 <h1>Daily MIXX is not available yet. Check back soon!</h1>;
+ }
+
+ if (isGameOver) {
return (
<Result
didGuess={didGuess}
@@ -43,6 +74,7 @@ export function Game({
/>
);
}
+
return (
<>
{guesses.map((guess: GuessType, index) => (
@@ -55,7 +87,6 @@ export function Game({
)}
<Search currentTry={currentTry} setSelectedSong={setSelectedSong} />
-
<Styled.Buttons>
<Button onClick={skip}>
{currentTry === 5
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage