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

Commit

Permalink
Merge pull request #6886 from matrix-org/t3chguy/fix/19223
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Sep 29, 2021
2 parents 7e47211 + 56745f2 commit fbf74be
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/stores/SpaceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
* should not be done when the space switch is done implicitly due to another event like switching room.
*/
public setActiveSpace(space: Room | null, contextSwitch = true) {
if (space === this.activeSpace || (space && !space.isSpaceRoom())) return;
if (!this.matrixClient || space === this.activeSpace || (space && !space.isSpaceRoom())) return;

this._activeSpace = space;
this.emit(UPDATE_SELECTED_SPACE, this.activeSpace);
Expand All @@ -197,7 +197,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
// else if the last viewed room in this space is joined then view that
// else view space home or home depending on what is being clicked on
if (space?.getMyMembership() !== "invite" &&
this.matrixClient?.getRoom(roomId)?.getMyMembership() === "join" &&
this.matrixClient.getRoom(roomId)?.getMyMembership() === "join" &&
this.getSpaceFilteredRoomIds(space).has(roomId)
) {
defaultDispatcher.dispatch({
Expand Down Expand Up @@ -230,7 +230,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
}
}

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

private rebuild = throttle(() => {
if (!this.matrixClient) return;

const [visibleSpaces, visibleRooms] = partitionSpacesAndRooms(this.matrixClient.getVisibleRooms());
const [joinedSpaces, invitedSpaces] = visibleSpaces.reduce((arr, s) => {
if (s.getMyMembership() === "join") {
Expand Down Expand Up @@ -751,7 +753,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
}

protected async onAction(payload: ActionPayload) {
if (!spacesEnabled || !this.matrixClient) return;
if (!spacesEnabled) return;
switch (payload.action) {
case "view_room": {
// Don't auto-switch rooms when reacting to a context-switch
Expand Down

0 comments on commit fbf74be

Please sign in to comment.