@@ -15,7 +15,7 @@ import {
1515 BotOrNotIcon ,
1616} from 'src/components/Common/Icons'
1717import { PlayType } from 'src/types'
18- import { getGlobalStats } from 'src/api'
18+ import { getGlobalStats , getActiveUserCount } from 'src/api'
1919import { AuthContext , ModalContext } from 'src/contexts'
2020import { AnimatedNumber } from 'src/components/Common/AnimatedNumber'
2121
@@ -120,6 +120,7 @@ export const HomeHero: React.FC<Props> = ({ scrollHandler }: Props) => {
120120 puzzle_games_total : number
121121 turing_games_total : number
122122 } > ( )
123+ const [ activeUsers , setActiveUsers ] = useState < number > ( 0 )
123124 const { setPlaySetupModalProps } = useContext ( ModalContext )
124125 const { user, connectLichess } = useContext ( AuthContext )
125126
@@ -130,13 +131,30 @@ export const HomeHero: React.FC<Props> = ({ scrollHandler }: Props) => {
130131 [ setPlaySetupModalProps ] ,
131132 )
132133
134+ // Fetch initial data
133135 useEffect ( ( ) => {
134136 ; ( async ( ) => {
135137 const data = await getGlobalStats ( )
136138 setGlobalStats ( data )
137139 } ) ( )
138140 } , [ ] )
139141
142+ // Fetch active users count and set up periodic updates
143+ useEffect ( ( ) => {
144+ const fetchActiveUsers = async ( ) => {
145+ const count = await getActiveUserCount ( )
146+ setActiveUsers ( count )
147+ }
148+
149+ // Fetch immediately
150+ fetchActiveUsers ( )
151+
152+ // Update every 30 seconds
153+ const interval = setInterval ( fetchActiveUsers , 30000 )
154+
155+ return ( ) => clearInterval ( interval )
156+ } , [ ] )
157+
140158 return (
141159 < Fragment >
142160 < BetaBlurb />
@@ -227,7 +245,14 @@ export const HomeHero: React.FC<Props> = ({ scrollHandler }: Props) => {
227245 />
228246 </ div >
229247 </ div >
230- < motion . div className = "grid grid-cols-3 gap-6 px-2 md:flex" >
248+ < motion . div className = "grid grid-cols-2 gap-6 px-2 md:flex md:gap-6" >
249+ < p className = "text-center text-base text-primary/80" >
250+ < AnimatedNumber
251+ value = { activeUsers }
252+ className = "font-bold text-human-4"
253+ /> { ' ' }
254+ users online
255+ </ p >
231256 < p className = "text-center text-base text-primary/80" >
232257 < AnimatedNumber
233258 value = { globalStats ?. play_moves_total || 0 }
0 commit comments