From 7a97b80861c2274026d871dc344c0c4cec59cbcf Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Fri, 9 Aug 2024 16:18:52 +0100 Subject: [PATCH] Always store latest fingerprints Should reduce unnecessary retransmits --- src/matrixrtc/MatrixRTCSession.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/matrixrtc/MatrixRTCSession.ts b/src/matrixrtc/MatrixRTCSession.ts index 9eef5405e8..d8a18b91f6 100644 --- a/src/matrixrtc/MatrixRTCSession.ts +++ b/src/matrixrtc/MatrixRTCSession.ts @@ -650,6 +650,7 @@ export class MatrixRTCSession extends TypedEventEmitter { const oldMemberships = this.memberships; + const oldFingerprints = this.lastMembershipFingerprints; this.memberships = MatrixRTCSession.callMembershipsForRoom(this.room); this._callId = this._callId ?? this.memberships[0]?.callId; @@ -676,17 +677,18 @@ export class MatrixRTCSession extends TypedEventEmitter !newMembershipIds.has(x)); const anyJoined = Array.from(newMembershipIds).some((x) => !oldMembershipIds.has(x)); + // always store the fingerprints of these latest memberships + this.storeLastMembershipFingerprints(); + if (anyLeft) { logger.debug(`Member(s) have left: queueing sender key rotation`); this.makeNewKeyTimeout = setTimeout(this.onRotateKeyTimeout, MAKE_KEY_DELAY); } else if (anyJoined) { logger.debug(`New member(s) have joined: re-sending keys`); this.requestKeyEventSend(); - } else if (this.lastMembershipFingerprints) { + } else if (oldFingerprints) { // does it look like any of the members have updated their memberships? - const oldFingerprints = this.lastMembershipFingerprints; - this.storeLastMembershipFingerprints(); - const newFingerprints = this.lastMembershipFingerprints; + const newFingerprints = this.lastMembershipFingerprints!; // We can use https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/symmetricDifference // for this once available @@ -697,9 +699,6 @@ export class MatrixRTCSession extends TypedEventEmitter