From da4689d78f39aa6e99e2be6e38fdbd95e0ccccd2 Mon Sep 17 00:00:00 2001 From: skedwards88 Date: Sun, 5 May 2024 18:52:39 -0700 Subject: [PATCH] move the has visited logic --- src/components/App.js | 4 +--- src/logic/getInitialState.js | 5 ++++- src/logic/hasVisitedSince.js | 3 --- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/App.js b/src/components/App.js index 8edf64a..2355b01 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -13,7 +13,6 @@ 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); @@ -33,7 +32,6 @@ function parseUrlQuery() { export default function App() { const [seed, difficultyLevel] = parseUrlQuery(); - const hasVisited = hasVisitedSince(); const [lastVisited] = React.useState(getDailySeed()); React.useEffect(() => { window.localStorage.setItem( @@ -46,7 +44,7 @@ export default function App() { localStorage.getItem("blobbleDisplaySavedStateName"), ); const [display, setDisplay] = React.useState( - getInitialState(savedDisplay, hasVisited), + getInitialState(savedDisplay), ); const [installPromptEvent, setInstallPromptEvent] = React.useState(); diff --git a/src/logic/getInitialState.js b/src/logic/getInitialState.js index faa34f7..7259a4a 100644 --- a/src/logic/getInitialState.js +++ b/src/logic/getInitialState.js @@ -1,4 +1,7 @@ -export function getInitialState(savedDisplay, hasVisited) { +import { hasVisitedSince } from "./hasVisitedSince"; + +export function getInitialState(savedDisplay) { + const hasVisited = hasVisitedSince(); if (!hasVisited) { return "rules"; } diff --git a/src/logic/hasVisitedSince.js b/src/logic/hasVisitedSince.js index d150972..ebb0caf 100644 --- a/src/logic/hasVisitedSince.js +++ b/src/logic/hasVisitedSince.js @@ -13,8 +13,5 @@ export function hasVisitedSince() { const resetDate = convertYYYYMMDDToDate("20240429"); - console.log(lastVisitedDate); - console.log(resetDate); - console.log(lastVisitedDate >= resetDate); return lastVisitedDate >= resetDate; }