Remove LegacyCallHandler singleton (#34086)
* Remove dead code * Remove LegacyCallHandler singleton Route via SDKContext to cut import cycles * Remove unused setting * Fix tests * Fix tests * Cascade SDKContext through PersistedElement * Improve coverage * Iterate * Improve coverage * Improve coverage
This commit is contained in:
@@ -26,7 +26,6 @@ import { type ActionPayload } from "../dispatcher/payloads";
|
||||
import SettingsStore from "../settings/SettingsStore";
|
||||
import { CallStore } from "../stores/CallStore";
|
||||
import { type Call } from "../models/Call";
|
||||
import LegacyCallHandler from "../LegacyCallHandler";
|
||||
|
||||
vi.mock("../Modal.tsx");
|
||||
|
||||
@@ -84,7 +83,9 @@ describe("leaveRoomBehaviour", () => {
|
||||
};
|
||||
|
||||
it("hangs up legacy calls when leaving a room", async () => {
|
||||
const hangupSpy = vi.spyOn(LegacyCallHandler.instance, "hangupOrReject").mockImplementation(() => {});
|
||||
const hangupSpy = vi
|
||||
.spyOn(SDKContextClass.instance.legacyCallHandler, "hangupOrReject")
|
||||
.mockImplementation(() => {});
|
||||
|
||||
viewRoom(room);
|
||||
await leaveRoomBehaviour(client, room.roomId);
|
||||
|
||||
@@ -27,7 +27,6 @@ import { bulkSpaceBehaviour } from "./space";
|
||||
import { SDKContextClass } from "../contexts/SDKContextClass";
|
||||
import SettingsStore from "../settings/SettingsStore";
|
||||
import { CallStore } from "../stores/CallStore";
|
||||
import LegacyCallHandler from "../LegacyCallHandler";
|
||||
|
||||
export async function leaveRoomBehaviour(
|
||||
matrixClient: MatrixClient,
|
||||
@@ -64,7 +63,7 @@ export async function leaveRoomBehaviour(
|
||||
|
||||
// attempt to hang up legacy based calls
|
||||
try {
|
||||
LegacyCallHandler.instance.hangupOrReject(roomId);
|
||||
SDKContextClass.instance.legacyCallHandler.hangupOrReject(roomId);
|
||||
} catch (e) {
|
||||
logger.warn("Failed to hangup call before leaving room: ", e);
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ Please see LICENSE files in the repository root for full details.
|
||||
import { type CallType } from "matrix-js-sdk/src/webrtc/call";
|
||||
import { type Room } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import LegacyCallHandler from "../../LegacyCallHandler";
|
||||
import { getPlatformCallTypeProps, PlatformCallType } from "../../hooks/room/useRoomCall";
|
||||
import defaultDispatcher from "../../dispatcher/dispatcher";
|
||||
import { type ViewRoomPayload } from "../../dispatcher/payloads/ViewRoomPayload";
|
||||
import { Action } from "../../dispatcher/actions";
|
||||
import PosthogTrackers from "../../PosthogTrackers";
|
||||
import { SDKContextClass } from "../../contexts/SDKContextClass.ts";
|
||||
|
||||
/**
|
||||
* Helper to place a call in a room that works with all the legacy modes
|
||||
@@ -34,7 +34,7 @@ export const placeCall = async (
|
||||
PosthogTrackers.trackInteraction(analyticsName);
|
||||
|
||||
if (platformCallType == PlatformCallType.LegacyCall || platformCallType == PlatformCallType.JitsiCall) {
|
||||
await LegacyCallHandler.instance.placeCall(room.roomId, callType);
|
||||
await SDKContextClass.instance.legacyCallHandler.placeCall(room.roomId, callType);
|
||||
} else if (platformCallType == PlatformCallType.ElementCall) {
|
||||
defaultDispatcher.dispatch<ViewRoomPayload>({
|
||||
action: Action.ViewRoom,
|
||||
|
||||
Reference in New Issue
Block a user