fix(user): refresh profile on sidebar open

This commit is contained in:
2026-06-30 11:36:52 +08:00
parent 345c5f7f25
commit 6e811b0e09
4 changed files with 16 additions and 19 deletions
+13
View File
@@ -1,5 +1,6 @@
"use client";
import { useEffect } from "react";
import { LogOut } from "lucide-react";
import { signOut } from "next-auth/react";
import { useRouter } from "next/navigation";
@@ -29,6 +30,18 @@ export function SidebarScreen() {
const auth = useAuthState();
const authDispatch = useAuthDispatch();
useEffect(() => {
if (!auth.hasInitialized || auth.isLoading) return;
if (auth.loginStatus === "notLoggedIn") return;
userDispatch({ type: "UserFetch" });
}, [
auth.hasInitialized,
auth.isLoading,
auth.loginStatus,
userDispatch,
]);
const handleLogoutClick = () => {
userDispatch({ type: "UserClearLocal" });
authDispatch({ type: "AuthLogoutSubmitted" });