| 1 | import type { PullRequestCheck } from "@t3tools/contracts"; |
| 2 | |
| 3 | import { useLiveRefresh } from "./useLiveRefresh"; |
| 4 | |
| 5 | export function usePullRequestChecksRefresh(input: { |
| 6 | refresh: (() => void) | null; |
| 7 | enabled: boolean; |
| 8 | key: string; |
| 9 | checks: ReadonlyArray<PullRequestCheck>; |
| 10 | }) { |
| 11 | useLiveRefresh(input.refresh, { |
| 12 | key: input.key, |
| 13 | enabled: input.enabled, |
| 14 | intervalMs: |
| 15 | input.checks.length === 0 || |
| 16 | input.checks.some((check) => check.status === "pending" || check.status === "action-required") |
| 17 | ? 45_000 |
| 18 | : 60_000, |
| 19 | }); |
| 20 | } |