diff --git a/src/App.tsx b/src/App.tsx index 4a04744..1e7a35f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -74,6 +74,8 @@ export const App: FC<{}> = props => const [ prepareTrigger, setPrepareTrigger ] = useState(0); const warmupPromiseRef = useRef>(null); const rendererPromiseRef = useRef>(null); + const gameInitPromiseRef = useRef | null>(null); + const bootstrapDoneRef = useRef(false); const tickersStartedRef = useRef(false); const heartbeatIntervalRef = useRef(null); const rememberRotateIntervalRef = useRef(null); @@ -385,14 +387,26 @@ export const App: FC<{}> = props => const renderer = await startRenderer(width, height); await startWarmup(width, height); - await GetSessionDataManager().init(); - await GetRoomSessionManager().init(); - await GetRoomEngine().init(); - await GetCommunication().init(); - if(LegacyExternalInterface.available) LegacyExternalInterface.call('legacyTrack', 'authentication', 'authok', []); + if(!gameInitPromiseRef.current) + { + gameInitPromiseRef.current = (async () => + { + await GetSessionDataManager().init(); + await GetRoomSessionManager().init(); + await GetRoomEngine().init(); + await GetCommunication().init(); + })(); + } - HabboWebTools.sendHeartBeat(); + await gameInitPromiseRef.current; + + if(!bootstrapDoneRef.current) + { + bootstrapDoneRef.current = true; + if(LegacyExternalInterface.available) LegacyExternalInterface.call('legacyTrack', 'authentication', 'authok', []); + HabboWebTools.sendHeartBeat(); + } if(heartbeatIntervalRef.current !== null) window.clearInterval(heartbeatIntervalRef.current); heartbeatIntervalRef.current = window.setInterval(() => HabboWebTools.sendHeartBeat(), 10000); diff --git a/src/index.tsx b/src/index.tsx index 079795c..40553d6 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,4 +1,4 @@ -import { Suspense } from 'react'; +import { StrictMode, Suspense } from 'react'; import { createRoot } from 'react-dom/client'; import { ErrorBoundary } from 'react-error-boundary'; import { App } from './App'; @@ -44,15 +44,17 @@ import './css/toolbar/ToolBar.css'; import './css/widgets/FurnitureWidgets.css'; createRoot(document.getElementById('root')).render( - ( - - ) }> - }> - - - + + ( + + ) }> + }> + + + + );