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

544 migrate to react query v4 (#547)

* Update all imports

* Update isLoading

* Update onlineManager
This commit is contained in:
xmflsct
2022-12-10 14:47:19 +01:00
committed by GitHub
parent b449d50b78
commit 357c4039cb
48 changed files with 296 additions and 431 deletions

View File

@ -1,16 +1,17 @@
import apiInstance from '@api/instance'
import { AxiosError } from 'axios'
import { QueryFunctionContext, useQuery, UseQueryOptions } from 'react-query'
import { QueryFunctionContext, useQuery, UseQueryOptions } from '@tanstack/react-query'
export type QueryKeyAccount = ['Account', { id: Mastodon.Account['id'] }]
const accountQueryFunction = ({ queryKey }: QueryFunctionContext<QueryKeyAccount>) => {
const accountQueryFunction = async ({ queryKey }: QueryFunctionContext<QueryKeyAccount>) => {
const { id } = queryKey[1]
return apiInstance<Mastodon.Account>({
const res = await apiInstance<Mastodon.Account>({
method: 'get',
url: `accounts/${id}`
}).then(res => res.body)
})
return res.body
}
const useAccountQuery = ({
@ -27,15 +28,16 @@ const useAccountQuery = ({
export type QueryKeyAccountInLists = ['AccountInLists', { id: Mastodon.Account['id'] }]
const accountInListsQueryFunction = ({
const accountInListsQueryFunction = async ({
queryKey
}: QueryFunctionContext<QueryKeyAccountInLists>) => {
const { id } = queryKey[1]
return apiInstance<Mastodon.List[]>({
const res = await apiInstance<Mastodon.List[]>({
method: 'get',
url: `accounts/${id}/lists`
}).then(res => res.body)
})
return res.body
}
const useAccountInListsQuery = ({