Auto-select space if joined whilst being viewed

pull/21833/head
Michael Telatynski 2021-03-24 19:58:35 +00:00
parent 62172ba43d
commit a61f4c1811
1 changed files with 6 additions and 0 deletions

View File

@ -34,6 +34,7 @@ import {setHasDiff} from "../utils/sets";
import {objectDiff} from "../utils/objects"; import {objectDiff} from "../utils/objects";
import {arrayHasDiff} from "../utils/arrays"; import {arrayHasDiff} from "../utils/arrays";
import {ISpaceSummaryEvent, ISpaceSummaryRoom} from "../components/structures/SpaceRoomDirectory"; import {ISpaceSummaryEvent, ISpaceSummaryRoom} from "../components/structures/SpaceRoomDirectory";
import RoomViewStore from "./RoomViewStore";
type SpaceKey = string | symbol; type SpaceKey = string | symbol;
@ -368,6 +369,11 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
this.onRoomsUpdate(); this.onRoomsUpdate();
} }
// if the user was looking at the room and then joined select that space
if (room.getMyMembership() === "join" && room.roomId === RoomViewStore.getRoomId()) {
this.setActiveSpace(room);
}
const numSuggestedRooms = this._suggestedRooms.length; const numSuggestedRooms = this._suggestedRooms.length;
this._suggestedRooms = this._suggestedRooms.filter(r => r.room_id !== room.roomId); this._suggestedRooms = this._suggestedRooms.filter(r => r.room_id !== room.roomId);
if (numSuggestedRooms !== this._suggestedRooms.length) { if (numSuggestedRooms !== this._suggestedRooms.length) {