mirror of
https://github.com/RSSNext/Folo.git
synced 2026-10-29 03:46:58 +08:00
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>
13 lines
687 B
TypeScript
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))
|