OpenHands / frontend /src /hooks /query /use-repository-branches.ts
Backup-bdg's picture
Upload 565 files
b59aa07 verified
raw
history blame contribute delete
478 Bytes
import { useQuery } from "@tanstack/react-query";
import OpenHands from "#/api/open-hands";
import { Branch } from "#/types/git";
export const useRepositoryBranches = (repository: string | null) =>
useQuery<Branch[]>({
queryKey: ["repository", repository, "branches"],
queryFn: async () => {
if (!repository) return [];
return OpenHands.getRepositoryBranches(repository);
},
enabled: !!repository,
staleTime: 1000 * 60 * 5, // 5 minutes
});