Skip to content

Commit

Permalink
move the has visited logic
Browse files Browse the repository at this point in the history
  • Loading branch information
skedwards88 committed May 6, 2024
1 parent adbe776 commit da4689d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(
Expand All @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/logic/getInitialState.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export function getInitialState(savedDisplay, hasVisited) {
import { hasVisitedSince } from "./hasVisitedSince";

export function getInitialState(savedDisplay) {
const hasVisited = hasVisitedSince();
if (!hasVisited) {
return "rules";
}
Expand Down
3 changes: 0 additions & 3 deletions src/logic/hasVisitedSince.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@ export function hasVisitedSince() {

const resetDate = convertYYYYMMDDToDate("20240429");

console.log(lastVisitedDate);
console.log(resetDate);
console.log(lastVisitedDate >= resetDate);
return lastVisitedDate >= resetDate;
}

0 comments on commit da4689d

Please sign in to comment.