"use client"; import Link from "next/link"; import { HoverCard, HoverCardTrigger, HoverCardContent } from "@/components/ui/hover-card"; import { Loader2Icon } from "lucide-react"; import { useEffect, useState } from "react"; import { useDomain } from "@/hooks/useDomain"; import { getConnectionInProgressRepos, getConnections } from "@/actions"; import { isServiceError } from "@/lib/utils"; interface InProgress { connectionId: number; repoId: number; repoName: string; } export const ProgressNavIndicator = () => { const domain = useDomain(); const [inProgressJobs, setInProgressJobs] = useState([]); useEffect(() => { const fetchInProgressJobs = async () => { const connections = await getConnections(domain); if (!isServiceError(connections)) { const allInProgressRepos: InProgress[] = []; for (const connection of connections) { const inProgressRepos = await getConnectionInProgressRepos(connection.id, domain); if (!isServiceError(inProgressRepos)) { allInProgressRepos.push(...inProgressRepos.map(repo => ({ connectionId: connection.id, ...repo }))); } } setInProgressJobs(prevJobs => { // Only update if the jobs have actually changed const jobsChanged = prevJobs.length !== allInProgressRepos.length || prevJobs.some((job, idx) => job.repoId !== allInProgressRepos[idx]?.repoId || job.repoName !== allInProgressRepos[idx]?.repoName ); return jobsChanged ? allInProgressRepos : prevJobs; }); } }; fetchInProgressJobs(); }, [domain]); if (inProgressJobs.length === 0) { return null; } return (
{inProgressJobs.length}

Indexing in Progress

The following repositories are currently being indexed:

{inProgressJobs.slice(0, 10).map(item => (
{item.repoName}
))} {inProgressJobs.length > 10 && (
And {inProgressJobs.length - 10} more...
)}
); };