about summary refs log tree commit diff
path: root/src/state/queries/email-verification-required.ts
blob: 94ff5cbc684c49b53d3a0fe19c33588b298e9009 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import {useQuery} from '@tanstack/react-query'

interface ServiceConfig {
  checkEmailConfirmed: boolean
}

export function useServiceConfigQuery() {
  return useQuery({
    queryKey: ['service-config'],
    queryFn: async () => {
      const res = await fetch(
        'https://api.bsky.app/xrpc/app.bsky.unspecced.getConfig',
      )
      if (!res.ok) {
        return {
          checkEmailConfirmed: false,
        }
      }

      const json = await res.json()
      return json as ServiceConfig
    },
    staleTime: 5 * 60 * 1000,
  })
}