Files
DIYgodandClaude Opus 5.5 77450d935b fix(ssr): show the signed-in user on the login page
The user provider writes the session user in an effect of the same
commit that mounts the login page's avatar, and jotai 3 subscribes
after that commit, so the avatar kept reading no user and the signed-in
view never showed who was signed in. Read whoami with
useAtomValueRawSync.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 08:48:42 +08:00

13 lines
687 B
TypeScript

import { createAtomHooks, jotaiStore } from "@follow/utils/jotai"
import type { AuthUser } from "@follow-app/client-sdk"
import { atom, useAtomValueRawSync } from "jotai"
const whoamiAtom = atom<Nullable<AuthUser>>(null)
export const [, , , , whoami, setWhoami] = createAtomHooks(whoamiAtom)
// The user provider writes the session user in an effect of the same commit that mounts the
// login page's avatar, which a plain useAtomValue subscription would miss
export const useWhoami = () => useAtomValueRawSync(whoamiAtom, { store: jotaiStore })
export const [, , useLoginModalShow, useSetLoginModalShow, getLoginModalShow, setLoginModalShow] =
createAtomHooks(atom<boolean>(false))