Step 8.3: Convert RoomViewStore to a more modern singleton for imports

This commit is contained in:
Travis Ralston 2022-03-22 23:26:30 -06:00
parent 8d2dba4102
commit d5ed1eb66e
24 changed files with 99 additions and 102 deletions

View file

@ -34,7 +34,7 @@ import { RoomNotificationStateStore } from "../notifications/RoomNotificationSta
import { DefaultTagID } from "../room-list/models";
import { EnhancedMap, mapDiff } from "../../utils/maps";
import { setDiff, setHasDiff } from "../../utils/sets";
import RoomViewStore from "../RoomViewStore";
import { RoomViewStore } from "../RoomViewStore";
import { Action } from "../../dispatcher/actions";
import { arrayHasDiff, arrayHasOrderChange } from "../../utils/arrays";
import { reorderLexicographically } from "../../utils/stringOrderField";
@ -804,7 +804,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
};
private switchSpaceIfNeeded = () => {
const roomId = RoomViewStore.getRoomId();
const roomId = RoomViewStore.instance.getRoomId();
if (!this.isRoomInSpace(this.activeSpace, roomId) && !this.matrixClient.getRoom(roomId)?.isSpaceRoom()) {
this.switchToRelatedSpace(roomId);
}
@ -855,7 +855,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
}
// if the room currently being viewed was just joined then switch to its related space
if (newMembership === "join" && room.roomId === RoomViewStore.getRoomId()) {
if (newMembership === "join" && room.roomId === RoomViewStore.instance.getRoomId()) {
this.switchToRelatedSpace(room.roomId);
}
}
@ -882,7 +882,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
this.emit(room.roomId);
}
if (membership === "join" && room.roomId === RoomViewStore.getRoomId()) {
if (membership === "join" && room.roomId === RoomViewStore.instance.getRoomId()) {
// if the user was looking at the space and then joined: select that space
this.setActiveSpace(room.roomId, false);
} else if (membership === "leave" && room.roomId === this.activeSpace) {