mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
fix: unattended component reload due to session changes (#407)
* fix: unattended component reload due to session changes When the session is updated, status goes back to loading then authenticated or unauthenticated. session.accessTokenExpires may also be updated. This triggered various component refresh at unattented times, and brake the user experience. By splitting to only what's needed with memoization, it will prevent unattented refresh. * review * review: change syntax
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
"use client";
|
||||
import { useSession, signOut, signIn } from "next-auth/react";
|
||||
import { signOut, signIn } from "next-auth/react";
|
||||
import useSessionStatus from "../lib/useSessionStatus";
|
||||
import { Spinner, Link } from "@chakra-ui/react";
|
||||
|
||||
export default function UserInfo() {
|
||||
const { status } = useSession();
|
||||
const sessionReady = status !== "loading";
|
||||
const isAuthenticated = status === "authenticated";
|
||||
const { isLoading, isAuthenticated } = useSessionStatus();
|
||||
|
||||
return !sessionReady ? (
|
||||
return isLoading ? (
|
||||
<Spinner size="xs" thickness="1px" className="mx-3" />
|
||||
) : !isAuthenticated ? (
|
||||
<Link
|
||||
|
||||
Reference in New Issue
Block a user