11'use client'
22
33import { motion } from 'framer-motion'
4- import { Activity , Clock3 , Cpu , Globe2 , Radio } from 'lucide-react'
4+ import { Activity , Cpu , Globe2 , Radio } from 'lucide-react'
55import { useEffect , useMemo , useState } from 'react'
66
7- import { cn } from '@/lib/utils'
8-
97import type { FreebuffLiveStats } from '@/server/live-stats'
108import type { LucideIcon } from 'lucide-react'
119
@@ -71,20 +69,14 @@ function projectPoint(lat: number, lon: number) {
7169
7270function useLiveStats ( initialStats : FreebuffLiveStats ) {
7371 const [ stats , setStats ] = useState ( initialStats )
74- const [ isRefreshing , setIsRefreshing ] = useState ( false )
7572
7673 useEffect ( ( ) => {
7774 let isMounted = true
7875
7976 async function refresh ( ) {
80- setIsRefreshing ( true )
81- try {
82- const response = await fetch ( '/api/live' , { cache : 'no-store' } )
83- if ( response . ok && isMounted ) {
84- setStats ( ( await response . json ( ) ) as FreebuffLiveStats )
85- }
86- } finally {
87- if ( isMounted ) setIsRefreshing ( false )
77+ const response = await fetch ( '/api/live' , { cache : 'no-store' } )
78+ if ( response . ok && isMounted ) {
79+ setStats ( ( await response . json ( ) ) as FreebuffLiveStats )
8880 }
8981 }
9082
@@ -95,25 +87,16 @@ function useLiveStats(initialStats: FreebuffLiveStats) {
9587 }
9688 } , [ ] )
9789
98- return { stats, isRefreshing }
90+ return stats
9991}
10092
101- function StatTile ( {
102- icon : Icon ,
103- label,
104- value,
105- } : {
106- icon : LucideIcon
107- label : string
108- value : string
109- } ) {
93+ function StatTile ( { label, value } : { label : string ; value : string } ) {
11094 return (
11195 < div className = "rounded-lg border border-white/10 bg-white/[0.04] p-4 shadow-[inset_0_1px_0_rgba(255,255,255,0.05)]" >
11296 < div className = "flex items-center justify-between gap-3" >
11397 < span className = "text-xs uppercase tracking-[0.18em] text-white/45" >
11498 { label }
11599 </ span >
116- < Icon className = "h-4 w-4 text-cyan-300" aria-hidden />
117100 </ div >
118101 < div className = "mt-3 min-h-10 text-3xl font-serif leading-none text-white" >
119102 { value }
@@ -334,7 +317,7 @@ export default function LiveClient({
334317} : {
335318 initialStats : FreebuffLiveStats
336319} ) {
337- const { stats, isRefreshing } = useLiveStats ( initialStats )
320+ const stats = useLiveStats ( initialStats )
338321 const topCountry = useMemo (
339322 ( ) =>
340323 stats . countries [ 0 ]
@@ -358,29 +341,14 @@ export default function LiveClient({
358341 Freebuff live
359342 </ h1 >
360343 </ div >
361- < div
362- className = { cn (
363- 'flex items-center gap-2 text-sm text-white/55' ,
364- isRefreshing && 'text-cyan-200' ,
365- ) }
366- aria-live = "polite"
367- >
368- < span className = "h-2 w-2 rounded-full bg-acid-matrix shadow-[0_0_18px_rgba(124,255,63,0.9)]" />
369- < span >
370- { isRefreshing
371- ? 'Refreshing'
372- : `Updated ${ formattedTime ( stats . generatedAt ) } ` }
373- </ span >
374- </ div >
375344 </ div >
376345
377346 < div className = "mt-8 grid grid-cols-1 gap-3 md:grid-cols-2" >
378347 < StatTile
379- icon = { Globe2 }
380348 label = "Live users"
381349 value = { stats . totalLiveUsers . toLocaleString ( ) }
382350 />
383- < StatTile icon = { Clock3 } label = "Top country" value = { topCountry } />
351+ < StatTile label = "Top country" value = { topCountry } />
384352 </ div >
385353 </ div >
386354 </ section >
0 commit comments