diff --git a/src/components/App.js b/src/components/App.js index 277cdb7..8edf64a 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -13,6 +13,7 @@ import {gameReducer} from "../logic/gameReducer"; import getDailySeed from "../common/getDailySeed"; import {gameIsSolvedQ} from "../logic/gameIsSolvedQ"; import {getInitialState} from "../logic/getInitialState"; +import {hasVisitedSince} from "../logic/hasVisitedSince"; function parseUrlQuery() { const searchParams = new URLSearchParams(document.location.search); @@ -32,6 +33,7 @@ function parseUrlQuery() { export default function App() { const [seed, difficultyLevel] = parseUrlQuery(); + const hasVisited = hasVisitedSince(); const [lastVisited] = React.useState(getDailySeed()); React.useEffect(() => { window.localStorage.setItem( @@ -43,7 +45,9 @@ export default function App() { const savedDisplay = JSON.parse( localStorage.getItem("blobbleDisplaySavedStateName"), ); - const [display, setDisplay] = React.useState(getInitialState(savedDisplay)); + const [display, setDisplay] = React.useState( + getInitialState(savedDisplay, hasVisited), + ); const [installPromptEvent, setInstallPromptEvent] = React.useState(); const [showInstallButton, setShowInstallButton] = React.useState(true); diff --git a/src/logic/getInitialState.js b/src/logic/getInitialState.js index 685d680..faa34f7 100644 --- a/src/logic/getInitialState.js +++ b/src/logic/getInitialState.js @@ -1,7 +1,4 @@ -import {hasVisitedSince} from "./hasVisitedSince"; - -export function getInitialState(savedDisplay) { - const hasVisited = hasVisitedSince(); +export function getInitialState(savedDisplay, hasVisited) { if (!hasVisited) { return "rules"; } diff --git a/src/logic/hasVisitedSince.js b/src/logic/hasVisitedSince.js index ebb0caf..d150972 100644 --- a/src/logic/hasVisitedSince.js +++ b/src/logic/hasVisitedSince.js @@ -13,5 +13,8 @@ export function hasVisitedSince() { const resetDate = convertYYYYMMDDToDate("20240429"); + console.log(lastVisitedDate); + console.log(resetDate); + console.log(lastVisitedDate >= resetDate); return lastVisitedDate >= resetDate; }