import { useQuery } from "@tanstack/react-query"; import { api, type Me } from "./api"; // The signed-in account, read from the ["me"] query cache. App owns the FETCHING query (gated on // setup state) and renders modules only once it has resolved to a real user — so anywhere inside the // authenticated module tree the cache is always populated. `enabled:false` makes this a passive // observer (no second fetch, which could 503 in setup mode) that still re-renders when the cache // updates (login, the 60s refetch, a Google-link round-trip). Lets modules read `me` from a hook // instead of having it prop-drilled through App. export function useMe(): Me { const { data } = useQuery({ queryKey: ["me"], queryFn: api.me, enabled: false }); return data as Me; }