Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940import { queryOptions, useQuery } from "@octanejs/tanstack-query";import type { TaskRunPage, TaskSummary } from "../../../shared/tasks";import { activeRun } from "../task-history";import type { CustomerQuerySession } from "../customer-query-session";import { useCustomerQuerySession } from "../customer-query-provider";import { callOwner, type SettingsConnection } from "../owner-rpc";
export function taskListOptions( session: CustomerQuerySession, connection: SettingsConnection,) { return queryOptions({ queryKey: session.key("tasks", "list"), enabled: !!session.getSnapshot().scope && !!connection?.isReady(), queryFn: ({ signal }) => callOwner<TaskSummary[]>(connection, "listTasks", [], signal), });}
export function useTaskListQuery( connection: SettingsConnection, busy: boolean, selected: string | null,) { const session = useCustomerQuerySession(); const options = taskListOptions(session, connection); return useQuery({ ...options, enabled: options.enabled && !busy, refetchInterval: () => session.client .getQueryData<TaskRunPage>( session.key("tasks", "history", selected ?? ""), ) ?.runs.some(activeRun) ? 3000 : 30_000, });}