From d31aa121567a377a3cca3028e2589342992b4d57 Mon Sep 17 00:00:00 2001 From: Timo <16718859+toger5@users.noreply.github.com> Date: Wed, 15 Dec 2021 18:06:37 +0100 Subject: [PATCH] Fix MaxListenersExceededWarning (#7389) --- src/components/structures/RoomView.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index 65966a05e4..73e5d4532c 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -658,6 +658,7 @@ export class RoomView extends React.Component { callState: callState, }); + CallHandler.instance.on(CallHandlerEvent.CallState, this.onCallState); window.addEventListener('beforeunload', this.onPageUnload); } @@ -675,7 +676,6 @@ export class RoomView extends React.Component { } componentDidUpdate() { - CallHandler.instance.addListener(CallHandlerEvent.CallState, this.onCallState); if (this.roomView.current) { const roomView = this.roomView.current; if (!roomView.ondrop) { @@ -769,6 +769,8 @@ export class RoomView extends React.Component { ); } + CallHandler.instance.off(CallHandlerEvent.CallState, this.onCallState); + // cancel any pending calls to the throttled updated this.updateRoomMembers.cancel();