From 1188d2f044b68809caa210052f0dd916bee619cb Mon Sep 17 00:00:00 2001 From: Johannes Horn Date: Mon, 23 Nov 2026 09:47:21 +0100 Subject: [PATCH] fix(frontend): clear the Apollo Client cache explicitly when logging out --- frontend/README.md | 4 +- frontend/app/components/Header/Header.tsx | 7 +-- .../MobileHeaderMenu/MobileHeaderMenu.tsx | 7 +-- frontend/app/hooks/useLogOut.test.tsx | 58 +++++++++++++++++++ frontend/app/hooks/useLogOut.ts | 25 ++++++++ frontend/app/routes/profile.tsx | 7 +-- 6 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 frontend/app/hooks/useLogOut.test.tsx create mode 100644 frontend/app/hooks/useLogOut.ts diff --git a/frontend/README.md b/frontend/README.md index 52c94d34..bb5d7c07 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -104,8 +104,8 @@ intended change without catching real bugs. profile page (`app/routes/`): the whole page is rendered with mocked API responses, for example searching, the suggestions when a search has no results, errors from the API, and browsing from one book to the next. -- **Hook tests** for `useBookSearchParams`, `usePageParam`, `useCountUp` and - `useDataIsDelayed`. +- **Hook tests** for `useBookSearchParams`, `usePageParam`, `useCountUp`, + `useDataIsDelayed` and `useLogOut`. - **Snapshot test** for `BookCard`. The rendered HTML is stored in `__snapshots__/` next to the test and compared on every run. If a markup change is intended, update the snapshot with `pnpm test -u`. diff --git a/frontend/app/components/Header/Header.tsx b/frontend/app/components/Header/Header.tsx index c62c5d66..f8711ca5 100644 --- a/frontend/app/components/Header/Header.tsx +++ b/frontend/app/components/Header/Header.tsx @@ -3,10 +3,12 @@ import { authClient } from "~/api/auth"; import { MobileHeaderMenu } from "~/components/MobileHeaderMenu/MobileHeaderMenu"; import { Button, buttonVariants } from "~/components/ui/Button"; import { DarkModeToggle } from "~/components/ui/DarkModeToggle"; +import { useLogOut } from "~/hooks/useLogOut"; import { cn } from "~/lib/utils"; function Header() { const { data: session, isPending } = authClient.useSession(); + const logOut = useLogOut(); return (
@@ -52,10 +54,7 @@ function Header() {