import { CurrentPersonResource } from '../types' import { useApiGet } from './use_api' import { currentPersonRequestArgs } from './use_current_person' export const useDirectMessagesEligible = (): boolean => { const { data: person, isFetched } = useApiGet(currentPersonRequestArgs) // This hook is used as a React Navigation `if:` predicate, which can't suspend, so this has // to return a real boolean synchronously. Until the /me fetch resolves, that means failing // closed to false rather than blocking so the route is briefly absent instead of the app hanging. if (!isFetched) return false return person?.directMessagesEligible ?? false }