From df4dd69c80961a786864563cf93f8114c129c53b Mon Sep 17 00:00:00 2001 From: Vitaly Date: Thu, 13 Feb 2025 23:37:34 +0300 Subject: [PATCH 1/3] feat: display reconnect button in pause menu when connection seems to be lost --- src/react/AppStatusProvider.tsx | 14 +++++++------- src/react/PauseScreen.tsx | 11 +++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/react/AppStatusProvider.tsx b/src/react/AppStatusProvider.tsx index e0c620a7..955a2cc5 100644 --- a/src/react/AppStatusProvider.tsx +++ b/src/react/AppStatusProvider.tsx @@ -44,6 +44,13 @@ const saveReconnectOptions = (options: ConnectOptions) => { })) } +export const reconnectReload = () => { + if (lastConnectOptions.value) { + saveReconnectOptions(lastConnectOptions.value) + window.location.reload() + } +} + export default () => { const { isError, lastStatus, maybeRecoverable, status, hideDots, descriptionHint, loadingChunksData, loadingChunksDataPlayerChunk, minecraftJsonMessage, showReconnect } = useSnapshot(appStatusState) const { active: replayActive } = useSnapshot(packetsReplaceSessionState) @@ -70,13 +77,6 @@ export default () => { })) } - const reconnectReload = () => { - if (lastConnectOptions.value) { - saveReconnectOptions(lastConnectOptions.value) - window.location.reload() - } - } - useEffect(() => { const controller = new AbortController() window.addEventListener('keyup', (e) => { diff --git a/src/react/PauseScreen.tsx b/src/react/PauseScreen.tsx index 01edaa13..0d2f0fab 100644 --- a/src/react/PauseScreen.tsx +++ b/src/react/PauseScreen.tsx @@ -12,7 +12,8 @@ import { showModal, hideModal, miscUiState, - openOptionsMenu + openOptionsMenu, + gameAdditionalState } from '../globalState' import { fsState } from '../loadSave' import { disconnect } from '../flyingSquidUtils' @@ -28,7 +29,7 @@ import Screen from './Screen' import styles from './PauseScreen.module.css' import { DiscordButton } from './DiscordButton' import { showNotification } from './NotificationProvider' -import { appStatusState } from './AppStatusProvider' +import { appStatusState, reconnectReload } from './AppStatusProvider' const waitForPotentialRender = async () => { return new Promise(resolve => { @@ -153,6 +154,7 @@ export default () => { const fsStateSnap = useSnapshot(fsState) const activeModalStackSnap = useSnapshot(activeModalStack) const { singleplayer, wanOpened, wanOpening } = useSnapshot(miscUiState) + const { noConnection } = useSnapshot(gameAdditionalState) const handlePointerLockChange = () => { if (!pointerLock.hasPointerLock && activeModalStack.length === 0) { @@ -254,6 +256,11 @@ export default () => { /> ) : null} + {noConnection && ( + + )} {!lockConnect && <>