File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "version" : " 1.0.1" ,
3+ "buildTime" : " 2025-12-26T22:46:00Z"
4+ }
Original file line number Diff line number Diff line change @@ -101,6 +101,32 @@ function App() {
101101 const [ lastBlunderTime , setLastBlunderTime ] = useState ( 0 ) ;
102102 const blunderCooldown = 10000 ; // 10 seconds cooldown between blunders
103103
104+ // Auto-reload when new version is deployed
105+ const currentVersion = useRef ( null ) ;
106+ useEffect ( ( ) => {
107+ const checkVersion = async ( ) => {
108+ try {
109+ const response = await fetch ( '/version.json?t=' + Date . now ( ) , { cache : 'no-store' } ) ;
110+ if ( response . ok ) {
111+ const data = await response . json ( ) ;
112+ if ( currentVersion . current === null ) {
113+ currentVersion . current = data . version ;
114+ console . log ( 'App version:' , data . version ) ;
115+ } else if ( currentVersion . current !== data . version ) {
116+ console . log ( 'New version detected, reloading...' , data . version ) ;
117+ window . location . reload ( true ) ;
118+ }
119+ }
120+ } catch ( error ) {
121+ console . log ( 'Version check failed:' , error ) ;
122+ }
123+ } ;
124+
125+ checkVersion ( ) ; // Check immediately on load
126+ const interval = setInterval ( checkVersion , 60000 ) ; // Check every 60 seconds
127+ return ( ) => clearInterval ( interval ) ;
128+ } , [ ] ) ;
129+
104130 const handleBlunder = ( linkIndex ) => {
105131 const currentTime = Date . now ( ) ;
106132 if ( ! isGameDataLoaded || currentTime - lastBlunderTime < blunderCooldown ) {
You can’t perform that action at this time.
0 commit comments