sailfork / t3code-github / apps/ web/ src/ hooks/ usePullRequestChecksRefresh.ts

import { pullRequestChecksRefreshIntervalMs } from "@t3tools/client-runtime/pull-request-checks";
import type { PullRequestCheck } from "@t3tools/contracts";

import { useLiveRefresh } from "./useLiveRefresh";

export function usePullRequestChecksRefresh(input: {
  refresh: (() => void) | null;
  enabled: boolean;
  key: string;
  checks: ReadonlyArray<PullRequestCheck>;
}) {
  useLiveRefresh(input.refresh, {
    key: input.key,
    enabled: input.enabled,
    intervalMs: pullRequestChecksRefreshIntervalMs(input.checks),
  });
}