From 4a2f82f06490b7fb277dc6c7558d10c34503a495 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Wed, 3 Jun 2026 01:38:53 -0700 Subject: add basic daily answer encryption --- src/app.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/app.tsx') diff --git a/src/app.tsx b/src/app.tsx index 7c4c81d..4eeccc8 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -3,8 +3,8 @@ import _ from "lodash"; import { Song } from "./types/song"; import { GuessState, GuessType } from "./types/guess"; +import { getDailySolution } from "./helpers/fetchSolution"; -import { todaysSolution } from "./helpers"; import { Header, InfoPopUp, Game, Footer } from "./components"; @@ -22,6 +22,7 @@ function App() { const [currentTry, setCurrentTry] = React.useState(0); const [selectedSong, setSelectedSong] = React.useState(); const [didGuess, setDidGuess] = React.useState(false); + const [todaysSolution, setTodaysSolution] = React.useState(null); const firstRun = localStorage.getItem("firstRun") === null; @@ -58,6 +59,10 @@ function App() { let stats = JSON.parse(localStorage.getItem("stats") || "{}"); let statsVersion = JSON.parse(localStorage.getItem("version") || "1"); + React.useEffect(() => { + getDailySolution().then(solution => setTodaysSolution(solution)); + }, []); + React.useEffect(() => { if (Array.isArray(stats)) { const visitedToday = _.isEqual( @@ -78,8 +83,6 @@ function App() { setDidGuess(didGuess); } } else { - // initialize stats - // useEffect below does rest stats = []; stats.push({ solution: todaysSolution, @@ -168,7 +171,7 @@ function App() { let state = GuessState.Incorrect; if (selectedSong === todaysSolution) { state = GuessState.Correct; - } else if (selectedSong?.artist === todaysSolution.artist) { + } else if (selectedSong?.artist === todaysSolution?.artist) { state = GuessState.PartiallyCorrect } @@ -195,6 +198,10 @@ function App() { } }, [guesses, selectedSong]); + if (todaysSolution === null) { + return null; + } + return (
-- cgit v1.2.3