From c019f2bb191b52f9bec496a4812b4c59fea758af Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 20 Jan 2023 12:09:28 +0000 Subject: [PATCH] Add null check for our own member event As per comment --- src/webrtc/groupCall.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/webrtc/groupCall.ts b/src/webrtc/groupCall.ts index 27bc6e3e8..f77145b36 100644 --- a/src/webrtc/groupCall.ts +++ b/src/webrtc/groupCall.ts @@ -1182,6 +1182,14 @@ export class GroupCall extends TypedEventEmitter< * Recalculates and updates the participant map to match the room state. */ private updateParticipants(): void { + const localMember = this.room.getMember(this.client.getUserId()!)!; + if (!localMember) { + // The client hasn't fetched enough of the room state to get our own member + // event. This probably shouldn't happen, but sanity check & exit for now. + logger.warn("Tried to update participants before local room member is available"); + return; + } + if (this.participantsExpirationTimer !== null) { clearTimeout(this.participantsExpirationTimer); this.participantsExpirationTimer = null; @@ -1236,7 +1244,6 @@ export class GroupCall extends TypedEventEmitter< // Apply local echo for the entered case if (entered) { - const localMember = this.room.getMember(this.client.getUserId()!)!; let deviceMap = participants.get(localMember); if (deviceMap === undefined) { deviceMap = new Map();