From 04e2917f959b77a10dee7ab0c3674223fd886d94 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Wed, 19 Feb 2025 16:36:17 +0100 Subject: [PATCH] fix: unlog redirect on login --- src/components/layout/Sidebar.tsx | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index 098d8eb..b9490b4 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -97,22 +97,25 @@ export function Sidebar({ isOpen, onClose }: SidebarProps) { await Promise.all([fetchLibraries(), fetchFavorites()]); }; - const handleLogout = () => { - authService.logout(); + const handleLogout = async () => { + await authService.logout(); setLibraries([]); setFavorites([]); onClose(); router.push("/login"); }; - const handleLinkClick = useCallback((path: string) => { - if (pathname === path) { + const handleLinkClick = useCallback( + (path: string) => { + if (pathname === path) { + onClose(); + return; + } + router.push(path); onClose(); - return; - } - router.push(path); - onClose(); - }, [pathname, router, onClose]); + }, + [pathname, router, onClose] + ); const navigation = [ {