You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-09 10:22:46 +03:00
Use non-legacy calls if any are found (#4337)
Akin to how legacy call events should be sent in rooms where there is any ongoing legacy call, send non-legacy events in rooms where there are only non-legacy calls; else fall back to the config preference.
This commit is contained in:
committed by
GitHub
parent
8c3b249567
commit
9176d3a671
@@ -826,9 +826,7 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
|
|||||||
if (!localUserId || !localDeviceId) throw new Error("User ID or device ID was null!");
|
if (!localUserId || !localDeviceId) throw new Error("User ID or device ID was null!");
|
||||||
|
|
||||||
const callMemberEvents = roomState.events.get(EventType.GroupCallMemberPrefix);
|
const callMemberEvents = roomState.events.get(EventType.GroupCallMemberPrefix);
|
||||||
const legacy =
|
const legacy = this.stateEventsContainOngoingLegacySession(callMemberEvents);
|
||||||
!!this.useLegacyMemberEvents ||
|
|
||||||
(callMemberEvents?.size && this.stateEventsContainOngoingLegacySession(callMemberEvents));
|
|
||||||
let newContent: {} | ExperimentalGroupCallRoomMemberState | SessionMembershipData = {};
|
let newContent: {} | ExperimentalGroupCallRoomMemberState | SessionMembershipData = {};
|
||||||
if (legacy) {
|
if (legacy) {
|
||||||
const myCallMemberEvent = callMemberEvents?.get(localUserId);
|
const myCallMemberEvent = callMemberEvents?.get(localUserId);
|
||||||
@@ -917,7 +915,13 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private stateEventsContainOngoingLegacySession(callMemberEvents: Map<string, MatrixEvent>): boolean {
|
private stateEventsContainOngoingLegacySession(callMemberEvents: Map<string, MatrixEvent> | undefined): boolean {
|
||||||
|
if (!callMemberEvents?.size) {
|
||||||
|
return this.useLegacyMemberEvents;
|
||||||
|
}
|
||||||
|
|
||||||
|
let containsAnyOngoingSession = false;
|
||||||
|
let containsUnknownOngoingSession = false;
|
||||||
for (const callMemberEvent of callMemberEvents.values()) {
|
for (const callMemberEvent of callMemberEvents.values()) {
|
||||||
const content = callMemberEvent.getContent();
|
const content = callMemberEvent.getContent();
|
||||||
if (Array.isArray(content["memberships"])) {
|
if (Array.isArray(content["memberships"])) {
|
||||||
@@ -926,9 +930,12 @@ export class MatrixRTCSession extends TypedEventEmitter<MatrixRTCSessionEvent, M
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (Object.keys(content).length > 0) {
|
||||||
|
containsAnyOngoingSession ||= true;
|
||||||
|
containsUnknownOngoingSession ||= !("focus_active" in content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return containsAnyOngoingSession && !containsUnknownOngoingSession ? false : this.useLegacyMemberEvents;
|
||||||
}
|
}
|
||||||
|
|
||||||
private makeMembershipStateKey(localUserId: string, localDeviceId: string): string {
|
private makeMembershipStateKey(localUserId: string, localDeviceId: string): string {
|
||||||
|
Reference in New Issue
Block a user