Spaces:
Build error
Build error
File size: 894 Bytes
b59aa07 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Query, useQuery } from "@tanstack/react-query";
import { AxiosError } from "axios";
import OpenHands from "#/api/open-hands";
import { Conversation } from "#/api/open-hands.types";
const FIVE_MINUTES = 1000 * 60 * 5;
const FIFTEEN_MINUTES = 1000 * 60 * 15;
type RefetchInterval = (
query: Query<
Conversation | null,
AxiosError<unknown, any>,
Conversation | null,
(string | null)[]
>,
) => number;
export const useUserConversation = (
cid: string | null,
refetchInterval?: RefetchInterval,
) =>
useQuery({
queryKey: ["user", "conversation", cid],
queryFn: async () => {
const conversation = await OpenHands.getConversation(cid!);
return conversation;
},
enabled: !!cid,
retry: false,
refetchInterval,
staleTime: FIVE_MINUTES,
gcTime: FIFTEEN_MINUTES,
});
|