MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / useHomepageLiveStats

Function useHomepageLiveStats

freebuff/web/src/app/live/live-summary.tsx:16–42  ·  view source on GitHub ↗
(initialStats: FreebuffLiveStats)

Source from the content-addressed store, hash-verified

14import type { LucideIcon } from 'lucide-react'
15
16function useHomepageLiveStats(initialStats: FreebuffLiveStats) {
17 const [isVisible, setIsVisible] = useState(false)
18 const sectionRef = useRef<HTMLElement>(null)
19 const stats = useLiveStats(initialStats, {
20 enabled: isVisible,
21 pauseWhenHidden: true,
22 refreshOnMount: true,
23 })
24
25 useEffect(() => {
26 const section = sectionRef.current
27 if (!section || !('IntersectionObserver' in window)) {
28 setIsVisible(true)
29 return
30 }
31
32 const observer = new IntersectionObserver(
33 ([entry]) => setIsVisible(entry.isIntersecting),
34 { rootMargin: '240px 0px', threshold: 0.01 },
35 )
36
37 observer.observe(section)
38 return () => observer.disconnect()
39 }, [])
40
41 return { sectionRef, stats }
42}
43
44function LiveRows({
45 title,

Callers 1

HomepageLiveStatsFunction · 0.85

Calls 1

useLiveStatsFunction · 0.90

Tested by

no test coverage detected