From 06c325bbaf9d12bd5ebb82888297a4ed489c905e Mon Sep 17 00:00:00 2001 From: Bartosz Prusinowski Date: Fri, 3 Nov 2023 15:06:27 +0100 Subject: [PATCH] fix: Flickering username --- app/login/utils.ts | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/app/login/utils.ts b/app/login/utils.ts index 667621a04..83b38ae4e 100644 --- a/app/login/utils.ts +++ b/app/login/utils.ts @@ -1,7 +1,6 @@ import { Theme } from "@mui/material"; import { makeStyles } from "@mui/styles"; -import { getProviders, useSession } from "next-auth/react"; -import React from "react"; +import { useSession } from "next-auth/react"; import { HEADER_HEIGHT } from "@/components/header"; @@ -24,39 +23,10 @@ export const useRootStyles = makeStyles((theme) => ({ export const useUser = () => { const { data: session, status: sessionStatus } = useSession(); - const { data: providers, status: providersStatus } = useProviders(); - if (sessionStatus === "loading" || providersStatus === "loading") { - return null; - } - - if (!providers || !Object.keys(providers).length) { - return null; - } - - if (!session) { + if (sessionStatus === "loading" || !session) { return null; } return session.user; }; - -type Providers = Awaited>; - -const useProviders = () => { - const [state, setState] = React.useState({ - status: "loading", - data: undefined as Providers | undefined, - }); - - React.useEffect(() => { - const run = async () => { - const providers = await getProviders(); - setState({ status: "loaded", data: providers }); - }; - - run(); - }, []); - - return state; -};