aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-06-03 19:23:33 -0700
committerPinapelz <yukais@pinapelz.com>2026-06-03 19:23:33 -0700
commite54a03e1329bd4711203ec8d49afcc1b095796af (patch)
tree5266148bdf535a07061337a3d991764ee4c95c41 /src/components
parent9244e32b4fd3c9c0013c99b7f7709cc7e723a6f3 (diff)
obfuscate solution in local storage, fix progress persistence
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Game/index.tsx8
-rw-r--r--src/components/Result/index.tsx15
2 files changed, 14 insertions, 9 deletions
diff --git a/src/components/Game/index.tsx b/src/components/Game/index.tsx
index 3b45329..cde682d 100644
--- a/src/components/Game/index.tsx
+++ b/src/components/Game/index.tsx
@@ -44,8 +44,9 @@ export function Game({
onPlayAgain,
}: Props) {
const [sessionDate] = React.useState(() => getUtcDate());
- const isGameOver = didGuess || currentTry === 6;
const recentFinishedPlay = localStorage.getItem("recentFinishedPlay");
+ const hasFinishedCurrentRound = didGuess || currentTry >= guesses.length;
+ const isGameOver = hasFinishedCurrentRound;
const isBlocked =
mode === "daily" &&
!!recentFinishedPlay &&
@@ -53,10 +54,11 @@ export function Game({
!checkDailyIsGenerated();
React.useEffect(() => {
- if (!isGameOver) return;
+ if (mode !== "daily") return;
+ if (!hasFinishedCurrentRound) return;
localStorage.setItem("recentFinishedPlay", sessionDate);
- }, [isGameOver, sessionDate]);
+ }, [mode, hasFinishedCurrentRound, sessionDate]);
if (isBlocked) {
return <h1>Daily MIXX is not available yet. Check back soon!</h1>;
diff --git a/src/components/Result/index.tsx b/src/components/Result/index.tsx
index 6b4560a..4ce7f35 100644
--- a/src/components/Result/index.tsx
+++ b/src/components/Result/index.tsx
@@ -100,14 +100,17 @@ export function Result({
mode = "daily",
onPlayAgain,
}: Props) {
- const hoursToNextDay = Math.floor(
- (new Date(new Date().setHours(24, 0, 0, 0)).getTime() -
- new Date().getTime()) /
- 1000 /
- 60 /
- 60
+ const now = new Date();
+ const nextUtcMidnight = Date.UTC(
+ now.getUTCFullYear(),
+ now.getUTCMonth(),
+ now.getUTCDate() + 1,
+ 0, 0, 0
);
+ const hoursToNextDay = Math.floor(
+ (nextUtcMidnight - now.getTime()) / 1000 / 60 / 60
+ );
const isUnlimited = mode === "unlimited";
if (didGuess) {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage