Skip to content

Commit f28fca7

Browse files
authored
Delete some unneeded code in the ElementCall class (#32879)
* Remove redundant call intent computation I'm not clear on why we've been computing the intent of a call twice — first in generateWidgetUrl and then again in getWidgetData. Adding intent to the widget's data has no effect at all since there is no matching placeholder in the URL for it to be templated into. It seems we can safely delete this code. * Remove preload hack Element Web has long since upgraded past version 0.15.0 of Element Call, so we no longer need to set the preload parameter manually.
1 parent 4f9a032 commit f28fca7

2 files changed

Lines changed: 5 additions & 54 deletions

File tree

apps/web/playwright/e2e/voip/element-call.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ function assertCommonCallParameters(
3737
expect(hash.get("userId")).toEqual(user.userId);
3838
expect(hash.get("deviceId")).toEqual(user.deviceId);
3939
expect(hash.get("roomId")).toEqual(room.roomId);
40-
expect(hash.get("preload")).toEqual("false");
4140
}
4241

4342
async function sendRTCState(bot: Bot, roomId: string, notification?: "ring" | "notification", intent?: string) {

apps/web/src/models/Call.ts

Lines changed: 5 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ export class ElementCall extends Call {
660660
): void {
661661
const room = client.getRoom(roomId);
662662
if (!room) {
663-
// If the room isn't known, or the room is a video room then skip setting an intent.
663+
// If the room isn't known then skip setting an intent.
664664
return;
665665
} else if (isVideoRoom(room)) {
666666
// Video rooms already exist, so just treat as if we're joining a group call.
@@ -669,35 +669,27 @@ export class ElementCall extends Call {
669669
params.append("returnToLobby", "true");
670670
// Never skip the lobby, we always want to give the caller a chance to explicitly join.
671671
params.append("skipLobby", "false");
672-
// Never preload, as per below warning.
673-
params.append("preload", "false");
674672
return;
675673
}
674+
676675
const isDM = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId);
677676
const oldestCallMember = client.matrixRTC.getRoomSession(room).getOldestMembership();
678677
const hasCallStarted = !!oldestCallMember && oldestCallMember.sender !== client.getSafeUserId();
679-
// XXX: @element-hq/element-call-embedded <= 0.15.0 sets the wrong parameter for
680-
// preload by default so we override here. This can be removed when that package
681-
// is released and upgraded.
682678
if (isDM) {
683679
if (hasCallStarted) {
684680
params.append(
685681
"intent",
686682
voiceOnly ? ElementCallIntent.JoinExistingDMVoice : ElementCallIntent.JoinExistingDM,
687683
);
688-
params.append("preload", "false");
689684
} else {
690685
params.append("intent", voiceOnly ? ElementCallIntent.StartCallDMVoice : ElementCallIntent.StartCallDM);
691-
params.append("preload", "false");
692686
}
693687
} else {
694688
// Group chats do not have a voice option.
695689
if (hasCallStarted) {
696690
params.append("intent", ElementCallIntent.JoinExisting);
697-
params.append("preload", "false");
698691
} else {
699692
params.append("intent", ElementCallIntent.StartCall);
700-
params.append("preload", "false");
701693
}
702694
}
703695
}
@@ -836,58 +828,18 @@ export class ElementCall extends Call {
836828
);
837829
}
838830

839-
/**
840-
* Get the correct intent for a widget, so that Element Call presents the correct
841-
* default config.
842-
* @param client The matrix client.
843-
* @param roomId
844-
* @param voiceOnly Should the call be voice-only, or video (default).
845-
*/
846-
public static getWidgetIntent(client: MatrixClient, roomId: string, voiceOnly?: boolean): ElementCallIntent {
847-
const room = client.getRoom(roomId);
848-
if (room !== null && !isVideoRoom(room)) {
849-
const isDM = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId);
850-
const oldestCallMember = client.matrixRTC.getRoomSession(room).getOldestMembership();
851-
const hasCallStarted = !!oldestCallMember && oldestCallMember.sender !== client.getSafeUserId();
852-
if (isDM) {
853-
if (hasCallStarted) {
854-
return voiceOnly ? ElementCallIntent.JoinExistingDMVoice : ElementCallIntent.JoinExistingDM;
855-
} else {
856-
return voiceOnly ? ElementCallIntent.StartCallDMVoice : ElementCallIntent.StartCallDM;
857-
}
858-
} else {
859-
if (hasCallStarted) {
860-
return ElementCallIntent.JoinExisting;
861-
} else {
862-
return ElementCallIntent.StartCall;
863-
}
864-
}
865-
}
866-
// If unknown, default to joining an existing call.
867-
return ElementCallIntent.JoinExisting;
868-
}
869-
870831
private static getWidgetData(
871832
client: MatrixClient,
872833
roomId: string,
873834
currentData: IWidgetData,
874835
overwriteData: IWidgetData,
875-
voiceOnly?: boolean,
876836
): IWidgetData {
877-
let perParticipantE2EE = false;
878-
if (
879-
client.getRoom(roomId)?.hasEncryptionStateEvent() &&
880-
!SettingsStore.getValue("feature_disable_call_per_sender_encryption")
881-
)
882-
perParticipantE2EE = true;
883-
884-
const intent = ElementCall.getWidgetIntent(client, roomId, voiceOnly);
885-
886837
return {
887838
...currentData,
888839
...overwriteData,
889-
intent,
890-
perParticipantE2EE,
840+
perParticipantE2EE:
841+
client.getRoom(roomId)?.hasEncryptionStateEvent() &&
842+
!SettingsStore.getValue("feature_disable_call_per_sender_encryption"),
891843
};
892844
}
893845

0 commit comments

Comments
 (0)