mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
* To MMKV migration working * POC migrated font size settings * Moved settings to mmkv * Fix typos * Migrated contexts slice * Migrated app slice * POC instance emoji update * Migrated drafts * Migrated simple instance properties * All migrated! * Re-structure files * Tolerant of undefined settings * Can properly logging in and out including empty state
35 lines
880 B
TypeScript
35 lines
880 B
TypeScript
import { QueryFunctionContext, useQuery, UseQueryOptions } from '@tanstack/react-query'
|
|
import apiInstance from '@utils/api/instance'
|
|
import { AxiosError } from 'axios'
|
|
|
|
export type QueryKeyStatusesHistory = [
|
|
'StatusesHistory',
|
|
{ id: Mastodon.Status['id'] }
|
|
]
|
|
|
|
const queryFunction = async ({
|
|
queryKey
|
|
}: QueryFunctionContext<QueryKeyStatusesHistory>) => {
|
|
const { id } = queryKey[1]
|
|
const res = await apiInstance<Mastodon.StatusHistory[]>({
|
|
method: 'get',
|
|
url: `statuses/${id}/history`
|
|
})
|
|
return res.body
|
|
}
|
|
|
|
const useStatusHistory = ({
|
|
options,
|
|
...queryKeyParams
|
|
}: QueryKeyStatusesHistory[1] & {
|
|
options?: UseQueryOptions<Mastodon.StatusHistory[], AxiosError>
|
|
}) => {
|
|
const queryKey: QueryKeyStatusesHistory = [
|
|
'StatusesHistory',
|
|
{ ...queryKeyParams }
|
|
]
|
|
return useQuery(queryKey, queryFunction, options)
|
|
}
|
|
|
|
export { useStatusHistory }
|