Skip to content

Commit 4ce837b

Browse files
authored
Fix sending call member events on leave (#3799)
#3756 changed the membership update function to await on the next call, but this meant it never returned and therefore never cleared `updateCallMembershipRunning`. We therefore didn't send the updated call member event when leaving, instead sending it whenever the next poll interval arrived. This changes it to only await if we are retrying, not if we're just scheduling the next poll. Fixes element-hq/element-call#1763
1 parent 884bd25 commit 4ce837b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/matrixrtc/MatrixRTCSession.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
427427
memberships: this.makeNewMemberships(memberships, myCallMemberEvent, myPrevMembership),
428428
};
429429

430-
let resendDelay = 0;
431430
try {
432431
await this.client.sendStateEvent(
433432
this.room.roomId,
@@ -438,13 +437,12 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
438437
logger.info(`Sent updated call member event.`);
439438

440439
// check periodically to see if we need to refresh our member event
441-
if (this.isJoined()) resendDelay = MEMBER_EVENT_CHECK_PERIOD;
440+
if (this.isJoined()) {
441+
this.memberEventTimeout = setTimeout(this.triggerCallMembershipEventUpdate, MEMBER_EVENT_CHECK_PERIOD);
442+
}
442443
} catch (e) {
443-
resendDelay = CALL_MEMBER_EVENT_RETRY_DELAY_MIN + Math.random() * 2000;
444+
const resendDelay = CALL_MEMBER_EVENT_RETRY_DELAY_MIN + Math.random() * 2000;
444445
logger.warn(`Failed to send call member event: retrying in ${resendDelay}`);
445-
}
446-
447-
if (resendDelay) {
448446
await new Promise((resolve) => setTimeout(resolve, resendDelay));
449447
await this.triggerCallMembershipEventUpdate();
450448
}

0 commit comments

Comments
 (0)