From 757d473971017e914f4bf4aad5bba697abb35728 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 1 Dec 2021 10:38:32 +0000 Subject: [PATCH] Fix automatic space switching wrongly going via Home for room aliases (#7247) --- src/stores/spaces/SpaceStore.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/stores/spaces/SpaceStore.ts b/src/stores/spaces/SpaceStore.ts index 34d8adafd8..9ec98cdeb1 100644 --- a/src/stores/spaces/SpaceStore.ts +++ b/src/stores/spaces/SpaceStore.ts @@ -50,6 +50,7 @@ import { UPDATE_SUGGESTED_ROOMS, UPDATE_TOP_LEVEL_SPACES, } from "."; +import { getCachedRoomIDForAlias } from "../../RoomAliasCache"; interface IState {} @@ -834,8 +835,14 @@ export class SpaceStoreClass extends AsyncStoreWithClient { // Don't auto-switch rooms when reacting to a context-switch // as this is not helpful and can create loops of rooms/space switching if (payload.context_switch) break; + let roomId = payload.room_id; + + if (payload.room_alias && !roomId) { + roomId = getCachedRoomIDForAlias(payload.room_alias); + } + + if (!roomId) return; // we'll get re-fired with the room ID shortly - const roomId = payload.room_id; const room = this.matrixClient?.getRoom(roomId); if (room?.isSpaceRoom()) { // Don't context switch when navigating to the space room