Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move hasVisited logic #3

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
Loading