Open History to see the last commit
1import { useEffect, useRef } from "react";
2import { DiffFileHeaderSkeleton } from "../DiffPanelShell";
3
4export function DiffFileLoadingBoundary({ load, count }: { load: () => void; count: number }) {
5 const ref = useRef<HTMLDivElement>(null);
6 useEffect(() => {
7 if (!ref.current) return;
8 const observer = new IntersectionObserver(
9 (entries) => {
10 if (entries.some((entry) => entry.isIntersecting)) load();
11 },
12 { rootMargin: "600px" },
13 );
14 observer.observe(ref.current);
15 return () => observer.disconnect();
16 }, [load]);
17 return (
18 <div ref={ref} role="status" aria-label="Loading diff…">
19 {Array.from({ length: Math.min(count, 4) }, (_, index) => (
20 <div key={index} aria-hidden className="border-b border-border/40">
21 <DiffFileHeaderSkeleton titleWidth="medium" />
22 </div>
23 ))}
24 </div>
25 );
26}