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 ++++++++---- src/components/Footer/index.tsx | 9 ++----- src/constants/index.ts | 2 +- src/data/songs.ts | 4 ++++ src/helpers/fetchSolution.ts | 52 +++++++++++++++++++++++++++++++++++++++++ src/helpers/fetchSongs.ts | 51 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 src/data/songs.ts create mode 100644 src/helpers/fetchSolution.ts create mode 100644 src/helpers/fetchSongs.ts (limited to 'src') 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 (
diff --git a/src/components/Footer/index.tsx b/src/components/Footer/index.tsx index e2747c3..3ba4c7c 100644 --- a/src/components/Footer/index.tsx +++ b/src/components/Footer/index.tsx @@ -20,13 +20,8 @@ export function Footer() { return (