From 9101b42de824b89dd67910b0e0814229e8c6ca09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Fri, 4 Nov 2022 14:49:31 +0100 Subject: [PATCH] Handle deletion of `m.call` events (#9540) --- src/models/Call.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/models/Call.ts b/src/models/Call.ts index c3ef2e6775..4276e4f973 100644 --- a/src/models/Call.ts +++ b/src/models/Call.ts @@ -23,10 +23,10 @@ import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state"; import { CallType } from "matrix-js-sdk/src/webrtc/call"; import { NamespacedValue } from "matrix-js-sdk/src/NamespacedValue"; import { IWidgetApiRequest, MatrixWidgetType } from "matrix-widget-api"; +import { MatrixEvent, MatrixEventEvent } from "matrix-js-sdk/src/models/event"; import type EventEmitter from "events"; import type { IMyDevice } from "matrix-js-sdk/src/client"; -import type { MatrixEvent } from "matrix-js-sdk/src/models/event"; import type { Room } from "matrix-js-sdk/src/models/room"; import type { RoomMember } from "matrix-js-sdk/src/models/room-member"; import type { ClientWidgetApi } from "matrix-widget-api"; @@ -656,6 +656,7 @@ export class ElementCall extends Call { client, ); + this.groupCall.on(MatrixEventEvent.BeforeRedaction, this.onBeforeRedaction); this.room.on(RoomStateEvent.Update, this.onRoomState); this.on(CallEvent.ConnectionState, this.onConnectionState); this.on(CallEvent.Participants, this.onParticipants); @@ -837,6 +838,7 @@ export class ElementCall extends Call { } public destroy() { + this.groupCall.off(MatrixEventEvent.BeforeRedaction, this.onBeforeRedaction); WidgetStore.instance.removeVirtualWidget(this.widget.id, this.groupCall.getRoomId()!); this.room.off(RoomStateEvent.Update, this.onRoomState); this.off(CallEvent.ConnectionState, this.onConnectionState); @@ -885,6 +887,10 @@ export class ElementCall extends Call { ); } + private onBeforeRedaction = (): void => { + this.disconnect(); + }; + private onRoomState = () => { this.updateParticipants();