fix(collection-confirm): hydrate actor from dev-identity cookie, not localStorage
This commit is contained in:
parent
d4b3f7c041
commit
6074e79be0
1 changed files with 12 additions and 10 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue