From d112b0117793a5ba121001395b1d8f9acf0006fa Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Wed, 2 Jul 2025 18:55:33 +0300 Subject: [PATCH] fix gameLoaded --- index.html | 2 +- src/appStatus.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 6471c495..b2fa3dbd 100644 --- a/index.html +++ b/index.html @@ -63,7 +63,7 @@ if (window.navigator.maxTouchPoints > 1) window.location.hash = '#dev' // show eruda // unregister all sw - if (window.navigator.serviceWorker) { + if (window.navigator.serviceWorker && document.querySelector('.initial-loader').style.opacity !== 0) { console.log('got worker') window.navigator.serviceWorker.getRegistrations().then(registrations => { registrations.forEach(registration => { diff --git a/src/appStatus.ts b/src/appStatus.ts index 054975f3..101714f5 100644 --- a/src/appStatus.ts +++ b/src/appStatus.ts @@ -1,3 +1,4 @@ +import { resetStateAfterDisconnect } from './browserfs' import { hideModal, activeModalStack, showModal, miscUiState } from './globalState' import { appStatusState, resetAppStatusState } from './react/AppStatusProvider' @@ -25,7 +26,6 @@ export const setLoadingScreenStatus = function (status: string | undefined | nul } showModal({ reactType: 'app-status' }) if (appStatusState.isError) { - miscUiState.gameLoaded = false return } appStatusState.hideDots = hideDots @@ -33,5 +33,9 @@ export const setLoadingScreenStatus = function (status: string | undefined | nul appStatusState.lastStatus = isError ? appStatusState.status : '' appStatusState.status = status appStatusState.minecraftJsonMessage = minecraftJsonMessage ?? null + + if (isError && miscUiState.gameLoaded) { + resetStateAfterDisconnect() + } } globalThis.setLoadingScreenStatus = setLoadingScreenStatus