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

Commit

Permalink
Handle deletion of m.call events (#9540)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBrandner authored Nov 4, 2022
1 parent 66d0b31 commit 9101b42
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit 9101b42

Please sign in to comment.