1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Test development branch

This commit is contained in:
Zhiyuan Zheng
2021-02-09 01:16:12 +01:00
parent 1f4108c2d4
commit c46888acab
9 changed files with 158 additions and 155 deletions

View File

@ -2,43 +2,17 @@ import client from '@api/client'
import { AxiosError } from 'axios'
import { useQuery, UseQueryOptions } from 'react-query'
export type QueryKey = [
'Instance',
{ instanceDomain?: string; checkPublic: boolean }
]
export type QueryKey = ['Instance', { instanceDomain?: string }]
const queryFunction = async ({ queryKey }: { queryKey: QueryKey }) => {
const { instanceDomain, checkPublic } = queryKey[1]
const queryFunction = ({ queryKey }: { queryKey: QueryKey }) => {
const { instanceDomain } = queryKey[1]
let res: Mastodon.Instance & { publicAllow?: boolean } = await client<
Mastodon.Instance
>({
return client<Mastodon.Instance>({
method: 'get',
instance: 'remote',
instanceDomain,
url: `instance`
})
if (checkPublic) {
let check
try {
check = await client<Mastodon.Status[]>({
method: 'get',
instance: 'remote',
instanceDomain,
url: `timelines/public`
})
} catch {}
if (check) {
res.publicAllow = true
return res
} else {
res.publicAllow = false
return res
}
}
return res
}
const useInstanceQuery = <