fix(call): leave call along with room (#33162)
* make sure to disconnect from possibly active calls for a room when leaving the room * log error on log call * Update apps/web/src/utils/leave-behaviour.ts Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> * fix wrong logger import * hang up calls properly on empty rooms for both legacy and element calls (listen for room event and leave call if only one member left). add tests for both legacy and element calls. * format Call-test.ts * revert async on function def * revert Call.ts and Call-test.ts. Wrap legacy call hangup in try --------- Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
co-authored by
Michael Telatynski
parent
abae870b83
commit
1044a95687
@@ -9,6 +9,7 @@ Please see LICENSE files in the repository root for full details.
|
||||
import { sleep } from "matrix-js-sdk/src/utils";
|
||||
import React, { type ReactNode } from "react";
|
||||
import { EventStatus, MatrixEventEvent, type Room, type MatrixClient, MatrixError } from "matrix-js-sdk/src/matrix";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import Modal, { type IHandle } from "../Modal";
|
||||
import Spinner from "../components/views/elements/Spinner";
|
||||
@@ -25,6 +26,8 @@ import { type AfterLeaveRoomPayload } from "../dispatcher/payloads/AfterLeaveRoo
|
||||
import { bulkSpaceBehaviour } from "./space";
|
||||
import { SdkContextClass } from "../contexts/SDKContext";
|
||||
import SettingsStore from "../settings/SettingsStore";
|
||||
import { CallStore } from "../stores/CallStore";
|
||||
import LegacyCallHandler from "../LegacyCallHandler";
|
||||
|
||||
export async function leaveRoomBehaviour(
|
||||
matrixClient: MatrixClient,
|
||||
@@ -59,6 +62,23 @@ export async function leaveRoomBehaviour(
|
||||
throw new Error(`Expected to find room for id ${roomId}`);
|
||||
}
|
||||
|
||||
// attempt to hang up legacy based calls
|
||||
try {
|
||||
LegacyCallHandler.instance.hangupOrReject(roomId);
|
||||
} catch (e) {
|
||||
logger.warn("Failed to hangup call before leaving room: ", e);
|
||||
}
|
||||
|
||||
// hang up widget based calls
|
||||
const activeCall = CallStore.instance.getActiveCall(roomId);
|
||||
if (activeCall) {
|
||||
try {
|
||||
await activeCall.disconnect();
|
||||
} catch (e) {
|
||||
logger.warn("Failed to disconnect call before leaving room: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
// await any queued messages being sent so that they do not fail
|
||||
await Promise.all(
|
||||
room
|
||||
|
||||
Reference in New Issue
Block a user