From ddf20b34d26bbb17aecd611561f78ba3505ac44f Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 1 Jan 2025 15:44:44 +0200 Subject: [PATCH] web/mainscreen: fix pushing history states when outside a space --- web/src/ui/MainScreen.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/ui/MainScreen.tsx b/web/src/ui/MainScreen.tsx index c735548..3bb15e6 100644 --- a/web/src/ui/MainScreen.tsx +++ b/web/src/ui/MainScreen.tsx @@ -139,7 +139,7 @@ class ContextFields implements MainScreenContextFields { room_id: roomID, source_via: meta?.via, source_alias: meta?.alias, - space_id: history.state.space_id, + space_id: history.state?.space_id, }, "") } } @@ -168,7 +168,7 @@ class ContextFields implements MainScreenContextFields { .querySelector(`div.room-entry[data-room-id="${CSS.escape(room.roomID)}"]`) ?.scrollIntoView({ block: "nearest" }) if (pushState) { - history.pushState({ room_id: room.roomID, space_id: history.state.space_id }, "") + history.pushState({ room_id: room.roomID, space_id: history.state?.space_id }, "") } let roomNameForTitle = room.meta.current.name if (roomNameForTitle && roomNameForTitle.length > 48) { @@ -186,7 +186,7 @@ class ContextFields implements MainScreenContextFields { this.client.store.activeRoomIsPreview = false this.keybindings.activeRoom = null if (pushState) { - history.pushState({ space_id: history.state.space_id }, "") + history.pushState({ space_id: history.state?.space_id }, "") } document.title = this.#getWindowTitle() }