fix(auth): clear query cache when user logs out from nav menu

This commit is contained in:
2026-06-23 23:19:09 +05:30
parent dfb95c5213
commit 6e16d4f2c8

View File

@@ -9,6 +9,7 @@ import {
Sparkles, Sparkles,
} from 'lucide-react'; } from 'lucide-react';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import { useQueryClient } from '@tanstack/react-query';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { import {
@@ -43,6 +44,7 @@ export function NavUser({
}) { }) {
const { isMobile } = useSidebar(); const { isMobile } = useSidebar();
const router = useRouter(); const router = useRouter();
const queryClient = useQueryClient();
const clearAuth = useAuthStore((state) => state.logout); const clearAuth = useAuthStore((state) => state.logout);
const clearApp = useAppStore((state) => state.clear); const clearApp = useAppStore((state) => state.clear);
const [isLoggingOut, setIsLoggingOut] = useState(false); const [isLoggingOut, setIsLoggingOut] = useState(false);
@@ -57,6 +59,7 @@ export function NavUser({
} catch { } catch {
// Local logout should still complete if the server session is already invalid. // Local logout should still complete if the server session is already invalid.
} finally { } finally {
queryClient.clear();
clearAuth(); clearAuth();
clearApp(); clearApp();
router.replace(ROUTES.LOGIN); router.replace(ROUTES.LOGIN);