Skip to content

Commit bd180ef

Browse files
committedOct 1, 2024·
fix: correctly lock URL when connected to a server (Y)
1 parent 0a0b87b commit bd180ef

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed
 

‎src/controls.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { getItemFromBlock } from './chatUtils'
2121
import { gamepadUiCursorState, moveGamepadCursorByPx } from './react/GamepadUiCursor'
2222
import { completeTexturePackInstall, resourcePackState } from './resourcePack'
2323
import { showNotification } from './react/NotificationProvider'
24+
import { lastConnectOptions } from './react/AppStatusProvider'
2425

2526

2627
export const customKeymaps = proxy(JSON.parse(localStorage.keymap || '{}')) as UserOverridesConfig
@@ -303,15 +304,17 @@ function lockUrl () {
303304
newQs = `loadSave=${save}`
304305
} else if (process.env.NODE_ENV === 'development') {
305306
newQs = `reconnect=1`
306-
} else {
307+
} else if (lastConnectOptions.value?.server) {
307308
const qs = new URLSearchParams()
308-
const { server, version } = localStorage
309+
const { server, botVersion } = lastConnectOptions.value
309310
qs.set('server', server)
310-
if (version) qs.set('version', version)
311+
if (botVersion) qs.set('version', botVersion)
311312
newQs = String(qs.toString())
312313
}
313314

314-
window.history.replaceState({}, '', `${window.location.pathname}?${newQs}`)
315+
if (newQs) {
316+
window.history.replaceState({}, '', `${window.location.pathname}?${newQs}`)
317+
}
315318
}
316319

317320
function cycleHotbarSlot (dir: 1 | -1) {

0 commit comments

Comments
 (0)
Please sign in to comment.