mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Lots of updates
This commit is contained in:
30
src/utils/queryHooks/relationship.ts
Normal file
30
src/utils/queryHooks/relationship.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import client from '@api/client'
|
||||
import { AxiosError } from 'axios'
|
||||
import { useQuery, UseQueryOptions } from 'react-query'
|
||||
|
||||
export type QueryKey = ['Relationship', { id: Mastodon.Account['id'] }]
|
||||
|
||||
const queryFunction = ({ queryKey }: { queryKey: QueryKey }) => {
|
||||
const { id } = queryKey[1]
|
||||
|
||||
return client<Mastodon.Relationship>({
|
||||
method: 'get',
|
||||
instance: 'local',
|
||||
url: `accounts/relationships`,
|
||||
params: {
|
||||
'id[]': id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const hookRelationship = <TData = Mastodon.Relationship>({
|
||||
options,
|
||||
...queryKeyParams
|
||||
}: QueryKey[1] & {
|
||||
options?: UseQueryOptions<Mastodon.Relationship, AxiosError, TData>
|
||||
}) => {
|
||||
const queryKey: QueryKey = ['Relationship', { ...queryKeyParams }]
|
||||
return useQuery(queryKey, queryFunction, options)
|
||||
}
|
||||
|
||||
export default hookRelationship
|
Reference in New Issue
Block a user