Skip to content

Commit

Permalink
Merge pull request #1107 from AletheiaFact/fixed-whoami-request-every…
Browse files Browse the repository at this point in the history
…-time-on-sidebar-click

Fixed ory whoami request every time on sidebar click
  • Loading branch information
thesocialdev authored Nov 19, 2023
2 parents 43d9036 + be74f2a commit df38e09
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/components/MainApp.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import { Layout } from "antd";
import { useSetAtom } from "jotai";
import React from "react";
import {
currentAuthentication,
currentUserId,
currentUserRole,
isUserLoggedIn,
} from "../atoms/currentUser";

import { useMediaQueryBreakpoints } from "../hooks/useMediaQueryBreakpoints";
import { useAppSelector } from "../store/store";
import colors from "../styles/colors";
import { GetUserRole } from "../utils/GetUserRole";
import ClaimReviewDrawer from "./ClaimReview/ClaimReviewDrawer";
import ContentWrapper from "./ContentWrapper";
import Footer from "./Footer/Footer";
Expand All @@ -26,16 +18,6 @@ const MainApp = ({ children }) => {
enableOverlay: state?.search?.overlayVisible,
};
});
const setCurrentRole = useSetAtom(currentUserRole);
const setCurrentLoginStatus = useSetAtom(isUserLoggedIn);
const setCurrentUserId = useSetAtom(currentUserId);
const setCurrentLevelAuthentication = useSetAtom(currentAuthentication);
GetUserRole().then(({ role, isLoggedIn, id, aal }) => {
setCurrentRole(role);
setCurrentLoginStatus(isLoggedIn);
setCurrentUserId(id);
setCurrentLevelAuthentication(aal);
});

// Setup to provide breakpoints object on redux
useMediaQueryBreakpoints();
Expand Down
20 changes: 20 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,30 @@ import colors from "../styles/colors";
import { DefaultSeo } from "next-seo";
import { CssBaseline, ThemeProvider } from "@mui/material";
import { materialTheme } from "../styles/materialTheme";
import { useSetAtom } from "jotai";
import {
currentAuthentication,
currentUserId,
currentUserRole,
isUserLoggedIn,
} from "../atoms/currentUser";
import { GetUserRole } from "../utils/GetUserRole";

function MyApp({ Component, pageProps }) {
const store = useStore();
const { t } = useTranslation();
const setCurrentRole = useSetAtom(currentUserRole);
const setCurrentLoginStatus = useSetAtom(isUserLoggedIn);
const setCurrentUserId = useSetAtom(currentUserId);
const setCurrentLevelAuthentication = useSetAtom(currentAuthentication);

GetUserRole().then(({ role, isLoggedIn, id, aal }) => {
setCurrentRole(role);
setCurrentLoginStatus(isLoggedIn);
setCurrentUserId(id);
setCurrentLevelAuthentication(aal);
});

return (
<>
<Head>
Expand Down

0 comments on commit df38e09

Please sign in to comment.