1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00
This commit is contained in:
Zhiyuan Zheng
2021-12-18 19:59:38 +01:00
parent ad6c6a98b6
commit 8c9dfb839b
23 changed files with 126 additions and 112 deletions

View File

@ -1,7 +1,11 @@
import apiInstance from '@api/instance'
import apiInstance, { InstanceResponse } from '@api/instance'
import { TabSharedStackParamList } from '@utils/navigation/navigators'
import { AxiosError } from 'axios'
import { useInfiniteQuery, UseInfiniteQueryOptions } from 'react-query'
import {
QueryFunctionContext,
useInfiniteQuery,
UseInfiniteQueryOptions
} from 'react-query'
export type QueryKeyUsers = [
'Users',
@ -11,10 +15,7 @@ export type QueryKeyUsers = [
const queryFunction = ({
queryKey,
pageParam
}: {
queryKey: QueryKeyUsers
pageParam?: { [key: string]: string }
}) => {
}: QueryFunctionContext<QueryKeyUsers>) => {
const { reference, id, type } = queryKey[1]
let params: { [key: string]: string } = { ...pageParam }
@ -30,15 +31,8 @@ const useUsersQuery = ({
...queryKeyParams
}: QueryKeyUsers[1] & {
options?: UseInfiniteQueryOptions<
{
body: Mastodon.Account[]
links?: { prev?: string; next?: string }
},
AxiosError,
{
body: Mastodon.Account[]
links?: { prev?: string; next?: string }
}
InstanceResponse<Mastodon.Account[]>,
AxiosError
>
}) => {
const queryKey: QueryKeyUsers = ['Users', { ...queryKeyParams }]