mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
26 lines
712 B
TypeScript
26 lines
712 B
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { getVcsInfo } from '@/api/opencode'
|
|
import { vcsInfoQueryKey } from '@/lib/queryInvalidation'
|
|
import { PERSISTED_CACHE_MAX_AGE_MS } from '@/lib/queryPersistence'
|
|
|
|
export interface UseVcsInfoOptions {
|
|
enabled?: boolean
|
|
}
|
|
|
|
export function useVcsInfo(
|
|
directory: string | undefined,
|
|
serverId: string | undefined,
|
|
options: UseVcsInfoOptions = {},
|
|
) {
|
|
const { enabled = true } = options
|
|
|
|
return useQuery({
|
|
queryKey: vcsInfoQueryKey(directory, serverId),
|
|
queryFn: () => getVcsInfo(directory ?? '', serverId),
|
|
enabled: enabled && Boolean(directory),
|
|
staleTime: 30_000,
|
|
gcTime: PERSISTED_CACHE_MAX_AGE_MS,
|
|
retry: false,
|
|
})
|
|
}
|