From bd180ef65221f2f19daa696d72536c3e5cf3a337 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Tue, 1 Oct 2024 10:18:52 +0300 Subject: [PATCH] fix: correctly lock URL when connected to a server (Y) --- src/controls.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/controls.ts b/src/controls.ts index 2edfdf53..6effdcd4 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -21,6 +21,7 @@ import { getItemFromBlock } from './chatUtils' import { gamepadUiCursorState, moveGamepadCursorByPx } from './react/GamepadUiCursor' import { completeTexturePackInstall, resourcePackState } from './resourcePack' import { showNotification } from './react/NotificationProvider' +import { lastConnectOptions } from './react/AppStatusProvider' export const customKeymaps = proxy(JSON.parse(localStorage.keymap || '{}')) as UserOverridesConfig @@ -303,15 +304,17 @@ function lockUrl () { newQs = `loadSave=${save}` } else if (process.env.NODE_ENV === 'development') { newQs = `reconnect=1` - } else { + } else if (lastConnectOptions.value?.server) { const qs = new URLSearchParams() - const { server, version } = localStorage + const { server, botVersion } = lastConnectOptions.value qs.set('server', server) - if (version) qs.set('version', version) + if (botVersion) qs.set('version', botVersion) newQs = String(qs.toString()) } - window.history.replaceState({}, '', `${window.location.pathname}?${newQs}`) + if (newQs) { + window.history.replaceState({}, '', `${window.location.pathname}?${newQs}`) + } } function cycleHotbarSlot (dir: 1 | -1) {