Skip to content

Commit

Permalink
move update condition into MembershipManager
Browse files Browse the repository at this point in the history
  • Loading branch information
toger5 committed Jan 10, 2025
1 parent e164f99 commit 506ec7f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/matrixrtc/MatrixRTCSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,11 +781,7 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
logger.info(`Memberships for call in room ${this.room.roomId} have changed: emitting`);
this.emit(MatrixRTCSessionEvent.MembershipsChanged, oldMemberships, this.memberships);

if (this.isJoined() && !this.memberships.some(this.isMyMembership)) {
logger.warn("Missing own membership: force re-join");
// TODO: Should this be awaited? And is there anything to tell the focus?
this.membershipManager?.onMembershipsUpdate();
}
this.membershipManager?.onMembershipsUpdate(this.memberships);
}

if (this.manageMediaKeys && this.isJoined()) {
Expand Down
13 changes: 10 additions & 3 deletions src/matrixrtc/MembershipManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface MembershipManagerInterface {
isJoined(): boolean;
join(fociPreferred: Focus[], fociActive?: Focus): void;
leave(timeout: number | undefined): Promise<boolean>;
onMembershipsUpdate(): Promise<void>;
onMembershipsUpdate(memberships: CallMembership[]): Promise<void>;
getActiveFocus(): Focus | undefined;
}

Expand Down Expand Up @@ -135,8 +135,15 @@ export class MembershipManager implements MembershipManagerInterface {
}
}

public async onMembershipsUpdate(): Promise<void> {
return this.triggerCallMembershipEventUpdate();
public async onMembershipsUpdate(memberships: CallMembership[]): Promise<void> {
const isMyMembership = (m: CallMembership): boolean =>
m.sender === this.client.getUserId() && m.deviceId === this.client.getDeviceId();

if (this.isJoined() && !memberships.some(isMyMembership)) {
logger.warn("Missing own membership: force re-join");
// TODO: Should this be awaited? And is there anything to tell the focus?
return this.triggerCallMembershipEventUpdate();
}
}

public getActiveFocus(): Focus | undefined {
Expand Down

0 comments on commit 506ec7f

Please sign in to comment.