Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit fbf74be

Browse files
authored
Merge pull request #6886 from matrix-org/t3chguy/fix/19223
2 parents 7e47211 + 56745f2 commit fbf74be

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/stores/SpaceStore.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
183183
* should not be done when the space switch is done implicitly due to another event like switching room.
184184
*/
185185
public setActiveSpace(space: Room | null, contextSwitch = true) {
186-
if (space === this.activeSpace || (space && !space.isSpaceRoom())) return;
186+
if (!this.matrixClient || space === this.activeSpace || (space && !space.isSpaceRoom())) return;
187187

188188
this._activeSpace = space;
189189
this.emit(UPDATE_SELECTED_SPACE, this.activeSpace);
@@ -197,7 +197,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
197197
// else if the last viewed room in this space is joined then view that
198198
// else view space home or home depending on what is being clicked on
199199
if (space?.getMyMembership() !== "invite" &&
200-
this.matrixClient?.getRoom(roomId)?.getMyMembership() === "join" &&
200+
this.matrixClient.getRoom(roomId)?.getMyMembership() === "join" &&
201201
this.getSpaceFilteredRoomIds(space).has(roomId)
202202
) {
203203
defaultDispatcher.dispatch({
@@ -230,7 +230,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
230230
}
231231
}
232232

233-
private async loadSuggestedRooms(space) {
233+
private async loadSuggestedRooms(space: Room): Promise<void> {
234234
const suggestedRooms = await this.fetchSuggestedRooms(space);
235235
if (this._activeSpace === space) {
236236
this._suggestedRooms = suggestedRooms;
@@ -335,6 +335,8 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
335335
};
336336

337337
private rebuild = throttle(() => {
338+
if (!this.matrixClient) return;
339+
338340
const [visibleSpaces, visibleRooms] = partitionSpacesAndRooms(this.matrixClient.getVisibleRooms());
339341
const [joinedSpaces, invitedSpaces] = visibleSpaces.reduce((arr, s) => {
340342
if (s.getMyMembership() === "join") {
@@ -751,7 +753,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
751753
}
752754

753755
protected async onAction(payload: ActionPayload) {
754-
if (!spacesEnabled || !this.matrixClient) return;
756+
if (!spacesEnabled) return;
755757
switch (payload.action) {
756758
case "view_room": {
757759
// Don't auto-switch rooms when reacting to a context-switch

0 commit comments

Comments
 (0)