Handle deletion of `m.call` events (#9540)

pull/28217/head
Šimon Brandner 2022-11-04 14:49:31 +01:00 committed by GitHub
parent 66d0b318bc
commit 9101b42de8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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();