File size: 748 Bytes
3d700dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { useQuery } from "@tanstack/react-query";
import {
  isAgentServerUnavailableError,
  isAgentServerAuthError,
} from "#/api/agent-server-compatibility";
import OptionService from "#/api/option-service/option-service.api";
import { QUERY_KEYS, CONFIG_CACHE_OPTIONS } from "./query-keys";

interface UseConfigOptions {
  enabled?: boolean;
}

export const useConfig = (options?: UseConfigOptions) =>
  useQuery({
    queryKey: QUERY_KEYS.WEB_CLIENT_CONFIG,
    queryFn: OptionService.getConfig,
    retry: (failureCount, error) =>
      !isAgentServerUnavailableError(error) &&
      !isAgentServerAuthError(error) &&
      failureCount < 3,
    meta: { disableToast: true },
    ...CONFIG_CACHE_OPTIONS,
    enabled: options?.enabled,
  });