Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Handle deletion of m.call events #9540

Merged
merged 2 commits into from
Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/models/Call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -885,6 +887,10 @@ export class ElementCall extends Call {
);
}

private onBeforeRedaction = (): void => {
this.disconnect();
};

private onRoomState = () => {
this.updateParticipants();

Expand Down