Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

serverReactQuery.ts

24 lines712 Bytes

1import { queryOptions } from "@tanstack/react-query";
2import { ensureNativeApi } from "~/nativeApi";
3​
4export const serverQueryKeys = {
5 all: ["server"] as const,
6 config: () => ["server", "config"] as const,
7};
8​
9/**
10 * Server config query options.
11 *
12 * `staleTime` is kept short so that push-driven `invalidateQueries` calls in
13 * the EventRouter always trigger a refetch, and so the query re-fetches when
14 * the component re-mounts (e.g. navigating away from settings and back).
15 */
16export function serverConfigQueryOptions() {
17 return queryOptions({
18 queryKey: serverQueryKeys.config(),
19 queryFn: async () => {
20 const api = ensureNativeApi();
21 return api.server.getConfig();
22 },
23 });