|
@@ -1,5 +1,6 @@
|
|
import React from "react";
|
|
import React from "react";
|
|
import type { AppProps } from "next/app";
|
|
import type { AppProps } from "next/app";
|
|
|
|
+import { useRouter } from "next/router";
|
|
import localFont from "@next/font/local";
|
|
import localFont from "@next/font/local";
|
|
import { init } from "@sentry/nextjs";
|
|
import { init } from "@sentry/nextjs";
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
@@ -9,6 +10,7 @@ import GlobalStyle from "src/constants/globalStyle";
|
|
import { darkTheme, lightTheme } from "src/constants/theme";
|
|
import { darkTheme, lightTheme } from "src/constants/theme";
|
|
import { ModalController } from "src/containers/ModalController";
|
|
import { ModalController } from "src/containers/ModalController";
|
|
import useStored from "src/store/useStored";
|
|
import useStored from "src/store/useStored";
|
|
|
|
+import useUser from "src/store/useUser";
|
|
import { ThemeProvider } from "styled-components";
|
|
import { ThemeProvider } from "styled-components";
|
|
|
|
|
|
const monaSans = localFont({
|
|
const monaSans = localFont({
|
|
@@ -35,14 +37,19 @@ const queryClient = new QueryClient({
|
|
});
|
|
});
|
|
|
|
|
|
function JsonCrack({ Component, pageProps }: AppProps) {
|
|
function JsonCrack({ Component, pageProps }: AppProps) {
|
|
- const [isReady, setReady] = React.useState(false);
|
|
|
|
|
|
+ const [isLoaded, setIsLoaded] = React.useState(false);
|
|
|
|
+ const { isReady } = useRouter();
|
|
const lightmode = useStored(state => state.lightmode);
|
|
const lightmode = useStored(state => state.lightmode);
|
|
|
|
+ const checkSession = useUser(state => state.checkSession);
|
|
|
|
|
|
React.useEffect(() => {
|
|
React.useEffect(() => {
|
|
- setReady(true);
|
|
|
|
- }, []);
|
|
|
|
|
|
+ if (isReady) {
|
|
|
|
+ checkSession();
|
|
|
|
+ }
|
|
|
|
+ setIsLoaded(true);
|
|
|
|
+ }, [checkSession, isReady]);
|
|
|
|
|
|
- if (isReady)
|
|
|
|
|
|
+ if (isLoaded)
|
|
return (
|
|
return (
|
|
<QueryClientProvider client={queryClient}>
|
|
<QueryClientProvider client={queryClient}>
|
|
<GoogleAnalytics />
|
|
<GoogleAnalytics />
|