From 6074e79be0c222871f9451e1a5d297949a6ef8a8 Mon Sep 17 00:00:00 2001 From: SJCoetz Date: Fri, 10 Jul 2026 01:01:24 +0200 Subject: [PATCH] fix(collection-confirm): hydrate actor from dev-identity cookie, not localStorage --- src/app/(app)/collection-confirm/page.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/app/(app)/collection-confirm/page.tsx b/src/app/(app)/collection-confirm/page.tsx index 0960416..2ad804c 100644 --- a/src/app/(app)/collection-confirm/page.tsx +++ b/src/app/(app)/collection-confirm/page.tsx @@ -9,6 +9,7 @@ import { Button } from "@/components/ui/button"; import { Checkbox } from "@/components/ui/checkbox"; import { ModalShell } from "@/components/ui/modal-shell"; import { getPocketBase } from "@/lib/pocketbase"; +import { getClientIdentity } from "@/lib/dev-identity"; import { cn } from "@/lib/utils"; import { @@ -150,16 +151,17 @@ export default function CollectionConfirmPage() { useEffect(() => { if (typeof window === "undefined") return; - const cached = window.localStorage?.getItem("wfdash.actor"); - if (cached) { - try { - const parsed = JSON.parse(cached) as ConfirmActor; - // eslint-disable-next-line react-hooks/set-state-in-effect -- hydrate actor from localStorage on mount - if (parsed?.id) setActor(parsed); - } catch { - /* ignore */ - } - } + // The dev-identity switcher writes the active email to the + // `wfdash_dev_email` cookie. The earlier localStorage-based + // hydration never matched because nothing wrote to localStorage. + // getClientIdentity() returns the cookie value or the default + // (DEFAULT_DEV_EMAIL) when unset, so the actor is never empty + // for a signed-in operator. + const email = getClientIdentity(); + if (!email) return; + const name = email.split("@")[0] || email; + // eslint-disable-next-line react-hooks/set-state-in-effect -- hydrate actor from dev-identity cookie on mount + setActor({ id: email, name }); }, []); const persistRow = useCallback(