({
worktreePath,
enabled = true,
refetchInterval = 10000,
}: UsePRStatusOptions)
| 20 | * Returns PR info, loading state, and refetch function. |
| 21 | */ |
| 22 | export function usePRStatus({ |
| 23 | worktreePath, |
| 24 | enabled = true, |
| 25 | refetchInterval = 10000, |
| 26 | }: UsePRStatusOptions): UsePRStatusResult { |
| 27 | const { |
| 28 | data: githubStatus, |
| 29 | isLoading, |
| 30 | refetch, |
| 31 | } = trpc.changes.getGitHubStatus.useQuery( |
| 32 | { worktreePath: worktreePath! }, |
| 33 | { |
| 34 | enabled: enabled && !!worktreePath, |
| 35 | refetchInterval, |
| 36 | }, |
| 37 | ); |
| 38 | |
| 39 | return { |
| 40 | pr: githubStatus?.pr ?? null, |
| 41 | repoUrl: githubStatus?.repoUrl ?? null, |
| 42 | branchExistsOnRemote: githubStatus?.branchExistsOnRemote ?? false, |
| 43 | isLoading, |
| 44 | refetch, |
| 45 | }; |
| 46 | } |
no outgoing calls
no test coverage detected