Skip to content

Commit f7b0cf5

Browse files
committed
Fix m.calls elements being null
Signed-off-by: Šimon Brandner <[email protected]>
1 parent b1695e2 commit f7b0cf5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/webrtc/groupCall.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,16 @@ export class GroupCall extends EventEmitter {
501501
const localUserId = this.client.getUserId();
502502

503503
const currentStateEvent = this.room.currentState.getStateEvents(EventType.GroupCallMemberPrefix, localUserId);
504+
const memberStateEvent = currentStateEvent?.getContent<IGroupCallRoomMemberState>();
504505

505-
const calls = currentStateEvent?.getContent<IGroupCallRoomMemberState>()["m.calls"] || [];
506-
507-
const existingCallIndex = calls.findIndex((call) => call["m.call_id"] === this.groupCallId);
506+
let calls: IGroupCallRoomMemberCallState[] = [];
507+
let existingCallIndex: number;
508+
if (memberCallState) {
509+
calls = memberStateEvent["m.calls"] || [];
510+
existingCallIndex = calls.findIndex((call) => call && call["m.call_id"] === this.groupCallId);
511+
} else {
512+
existingCallIndex = 0;
513+
}
508514

509515
if (existingCallIndex === -1) {
510516
calls.push(memberCallState);

0 commit comments

Comments
 (0)