Remove unit test function which isn't needed
The import ordering no longer requires us to create an injector function.
This commit is contained in:
parent
087c15171b
commit
5137fcf3e8
3 changed files with 6 additions and 19 deletions
|
@ -93,7 +93,6 @@ export class RoomViewStore extends Store<ActionPayload> {
|
||||||
public static readonly instance = new RoomViewStore();
|
public static readonly instance = new RoomViewStore();
|
||||||
|
|
||||||
private state = INITIAL_STATE; // initialize state
|
private state = INITIAL_STATE; // initialize state
|
||||||
private forcedMatrixClient: MatrixClient;
|
|
||||||
|
|
||||||
// Keep these out of state to avoid causing excessive/recursive updates
|
// Keep these out of state to avoid causing excessive/recursive updates
|
||||||
private roomIdActivityListeners: Record<string, Listener[]> = {};
|
private roomIdActivityListeners: Record<string, Listener[]> = {};
|
||||||
|
@ -102,14 +101,6 @@ export class RoomViewStore extends Store<ActionPayload> {
|
||||||
super(dis);
|
super(dis);
|
||||||
}
|
}
|
||||||
|
|
||||||
private get matrixClient(): MatrixClient {
|
|
||||||
return this.forcedMatrixClient || MatrixClientPeg.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public useUnitTestClient(client: MatrixClient) {
|
|
||||||
this.forcedMatrixClient = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public addRoomListener(roomId: string, fn: Listener) {
|
public addRoomListener(roomId: string, fn: Listener) {
|
||||||
if (!this.roomIdActivityListeners[roomId]) this.roomIdActivityListeners[roomId] = [];
|
if (!this.roomIdActivityListeners[roomId]) this.roomIdActivityListeners[roomId] = [];
|
||||||
this.roomIdActivityListeners[roomId].push(fn);
|
this.roomIdActivityListeners[roomId].push(fn);
|
||||||
|
@ -214,7 +205,7 @@ export class RoomViewStore extends Store<ActionPayload> {
|
||||||
this.setState({ shouldPeek: false });
|
this.setState({ shouldPeek: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
const cli = this.matrixClient;
|
const cli = MatrixClientPeg.get();
|
||||||
|
|
||||||
const updateMetrics = () => {
|
const updateMetrics = () => {
|
||||||
const room = cli.getRoom(payload.roomId);
|
const room = cli.getRoom(payload.roomId);
|
||||||
|
@ -290,7 +281,7 @@ export class RoomViewStore extends Store<ActionPayload> {
|
||||||
trigger: payload.metricsTrigger,
|
trigger: payload.metricsTrigger,
|
||||||
viaKeyboard: payload.metricsViaKeyboard,
|
viaKeyboard: payload.metricsViaKeyboard,
|
||||||
isDM: !!DMRoomMap.shared().getUserIdForRoomId(payload.room_id),
|
isDM: !!DMRoomMap.shared().getUserIdForRoomId(payload.room_id),
|
||||||
isSpace: this.matrixClient.getRoom(payload.room_id)?.isSpaceRoom(),
|
isSpace: MatrixClientPeg.get().getRoom(payload.room_id)?.isSpaceRoom(),
|
||||||
activeSpace,
|
activeSpace,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -349,7 +340,7 @@ export class RoomViewStore extends Store<ActionPayload> {
|
||||||
wasContextSwitch: payload.context_switch,
|
wasContextSwitch: payload.context_switch,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
const result = await this.matrixClient.getRoomIdForAlias(payload.room_alias);
|
const result = await MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias);
|
||||||
storeRoomAliasInCache(payload.room_alias, result.room_id);
|
storeRoomAliasInCache(payload.room_alias, result.room_id);
|
||||||
roomId = result.room_id;
|
roomId = result.room_id;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -386,7 +377,7 @@ export class RoomViewStore extends Store<ActionPayload> {
|
||||||
joining: true,
|
joining: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const cli = this.matrixClient;
|
const cli = MatrixClientPeg.get();
|
||||||
// take a copy of roomAlias & roomId as they may change by the time the join is complete
|
// take a copy of roomAlias & roomId as they may change by the time the join is complete
|
||||||
const { roomAlias, roomId } = this.state;
|
const { roomAlias, roomId } = this.state;
|
||||||
const address = roomAlias || roomId;
|
const address = roomAlias || roomId;
|
||||||
|
@ -418,7 +409,7 @@ export class RoomViewStore extends Store<ActionPayload> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getInvitingUserId(roomId: string): string {
|
private getInvitingUserId(roomId: string): string {
|
||||||
const cli = this.matrixClient;
|
const cli = MatrixClientPeg.get();
|
||||||
const room = cli.getRoom(roomId);
|
const room = cli.getRoom(roomId);
|
||||||
if (room && room.getMyMembership() === "invite") {
|
if (room && room.getMyMembership() === "invite") {
|
||||||
const myMember = room.getMember(cli.getUserId());
|
const myMember = room.getMember(cli.getUserId());
|
||||||
|
@ -443,7 +434,7 @@ export class RoomViewStore extends Store<ActionPayload> {
|
||||||
// only provide a better error message for invites
|
// only provide a better error message for invites
|
||||||
if (invitingUserId) {
|
if (invitingUserId) {
|
||||||
// if the inviting user is on the same HS, there can only be one cause: they left.
|
// if the inviting user is on the same HS, there can only be one cause: they left.
|
||||||
if (invitingUserId.endsWith(`:${this.matrixClient.getDomain()}`)) {
|
if (invitingUserId.endsWith(`:${MatrixClientPeg.get().getDomain()}`)) {
|
||||||
description = _t("The person who invited you has already left.");
|
description = _t("The person who invited you has already left.");
|
||||||
} else {
|
} else {
|
||||||
description = _t("The person who invited you has already left, or their server is offline.");
|
description = _t("The person who invited you has already left, or their server is offline.");
|
||||||
|
|
|
@ -32,7 +32,6 @@ import { RightPanelPhases } from "../../../src/stores/right-panel/RightPanelStor
|
||||||
import RightPanelStore from "../../../src/stores/right-panel/RightPanelStore";
|
import RightPanelStore from "../../../src/stores/right-panel/RightPanelStore";
|
||||||
import { UPDATE_EVENT } from "../../../src/stores/AsyncStore";
|
import { UPDATE_EVENT } from "../../../src/stores/AsyncStore";
|
||||||
import { WidgetLayoutStore } from "../../../src/stores/widgets/WidgetLayoutStore";
|
import { WidgetLayoutStore } from "../../../src/stores/widgets/WidgetLayoutStore";
|
||||||
import { RoomViewStore } from "../../../src/stores/RoomViewStore";
|
|
||||||
|
|
||||||
describe("RightPanel", () => {
|
describe("RightPanel", () => {
|
||||||
it("renders info from only one room during room changes", async () => {
|
it("renders info from only one room during room changes", async () => {
|
||||||
|
@ -76,7 +75,6 @@ describe("RightPanel", () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
await WidgetLayoutStore.instance.onReady();
|
await WidgetLayoutStore.instance.onReady();
|
||||||
RightPanelStore.instance.useUnitTestClient(cli);
|
RightPanelStore.instance.useUnitTestClient(cli);
|
||||||
RoomViewStore.instance.useUnitTestClient(cli);
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
await RightPanelStore.instance.onReady();
|
await RightPanelStore.instance.onReady();
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ import WidgetStore, { IApp } from "../../../../src/stores/WidgetStore";
|
||||||
import AppTile from "../../../../src/components/views/elements/AppTile";
|
import AppTile from "../../../../src/components/views/elements/AppTile";
|
||||||
import { Container, WidgetLayoutStore } from "../../../../src/stores/widgets/WidgetLayoutStore";
|
import { Container, WidgetLayoutStore } from "../../../../src/stores/widgets/WidgetLayoutStore";
|
||||||
import AppsDrawer from "../../../../src/components/views/rooms/AppsDrawer";
|
import AppsDrawer from "../../../../src/components/views/rooms/AppsDrawer";
|
||||||
import { RoomViewStore } from "../../../../src/stores/RoomViewStore";
|
|
||||||
|
|
||||||
describe("AppTile", () => {
|
describe("AppTile", () => {
|
||||||
let cli;
|
let cli;
|
||||||
|
@ -109,7 +108,6 @@ describe("AppTile", () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
await WidgetLayoutStore.instance.onReady();
|
await WidgetLayoutStore.instance.onReady();
|
||||||
RightPanelStore.instance.useUnitTestClient(cli);
|
RightPanelStore.instance.useUnitTestClient(cli);
|
||||||
RoomViewStore.instance.useUnitTestClient(cli);
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
await RightPanelStore.instance.onReady();
|
await RightPanelStore.instance.onReady();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue