mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-05 04:06:44 +02:00
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.
This commit is contained in:
parent
4f9a0321b5
commit
f28fca76eb
@ -37,7 +37,6 @@ function assertCommonCallParameters(
|
||||
expect(hash.get("userId")).toEqual(user.userId);
|
||||
expect(hash.get("deviceId")).toEqual(user.deviceId);
|
||||
expect(hash.get("roomId")).toEqual(room.roomId);
|
||||
expect(hash.get("preload")).toEqual("false");
|
||||
}
|
||||
|
||||
async function sendRTCState(bot: Bot, roomId: string, notification?: "ring" | "notification", intent?: string) {
|
||||
|
||||
@ -660,7 +660,7 @@ export class ElementCall extends Call {
|
||||
): void {
|
||||
const room = client.getRoom(roomId);
|
||||
if (!room) {
|
||||
// If the room isn't known, or the room is a video room then skip setting an intent.
|
||||
// If the room isn't known then skip setting an intent.
|
||||
return;
|
||||
} else if (isVideoRoom(room)) {
|
||||
// Video rooms already exist, so just treat as if we're joining a group call.
|
||||
@ -669,35 +669,27 @@ export class ElementCall extends Call {
|
||||
params.append("returnToLobby", "true");
|
||||
// Never skip the lobby, we always want to give the caller a chance to explicitly join.
|
||||
params.append("skipLobby", "false");
|
||||
// Never preload, as per below warning.
|
||||
params.append("preload", "false");
|
||||
return;
|
||||
}
|
||||
|
||||
const isDM = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId);
|
||||
const oldestCallMember = client.matrixRTC.getRoomSession(room).getOldestMembership();
|
||||
const hasCallStarted = !!oldestCallMember && oldestCallMember.sender !== client.getSafeUserId();
|
||||
// XXX: @element-hq/element-call-embedded <= 0.15.0 sets the wrong parameter for
|
||||
// preload by default so we override here. This can be removed when that package
|
||||
// is released and upgraded.
|
||||
if (isDM) {
|
||||
if (hasCallStarted) {
|
||||
params.append(
|
||||
"intent",
|
||||
voiceOnly ? ElementCallIntent.JoinExistingDMVoice : ElementCallIntent.JoinExistingDM,
|
||||
);
|
||||
params.append("preload", "false");
|
||||
} else {
|
||||
params.append("intent", voiceOnly ? ElementCallIntent.StartCallDMVoice : ElementCallIntent.StartCallDM);
|
||||
params.append("preload", "false");
|
||||
}
|
||||
} else {
|
||||
// Group chats do not have a voice option.
|
||||
if (hasCallStarted) {
|
||||
params.append("intent", ElementCallIntent.JoinExisting);
|
||||
params.append("preload", "false");
|
||||
} else {
|
||||
params.append("intent", ElementCallIntent.StartCall);
|
||||
params.append("preload", "false");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -836,58 +828,18 @@ export class ElementCall extends Call {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct intent for a widget, so that Element Call presents the correct
|
||||
* default config.
|
||||
* @param client The matrix client.
|
||||
* @param roomId
|
||||
* @param voiceOnly Should the call be voice-only, or video (default).
|
||||
*/
|
||||
public static getWidgetIntent(client: MatrixClient, roomId: string, voiceOnly?: boolean): ElementCallIntent {
|
||||
const room = client.getRoom(roomId);
|
||||
if (room !== null && !isVideoRoom(room)) {
|
||||
const isDM = !!DMRoomMap.shared().getUserIdForRoomId(room.roomId);
|
||||
const oldestCallMember = client.matrixRTC.getRoomSession(room).getOldestMembership();
|
||||
const hasCallStarted = !!oldestCallMember && oldestCallMember.sender !== client.getSafeUserId();
|
||||
if (isDM) {
|
||||
if (hasCallStarted) {
|
||||
return voiceOnly ? ElementCallIntent.JoinExistingDMVoice : ElementCallIntent.JoinExistingDM;
|
||||
} else {
|
||||
return voiceOnly ? ElementCallIntent.StartCallDMVoice : ElementCallIntent.StartCallDM;
|
||||
}
|
||||
} else {
|
||||
if (hasCallStarted) {
|
||||
return ElementCallIntent.JoinExisting;
|
||||
} else {
|
||||
return ElementCallIntent.StartCall;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If unknown, default to joining an existing call.
|
||||
return ElementCallIntent.JoinExisting;
|
||||
}
|
||||
|
||||
private static getWidgetData(
|
||||
client: MatrixClient,
|
||||
roomId: string,
|
||||
currentData: IWidgetData,
|
||||
overwriteData: IWidgetData,
|
||||
voiceOnly?: boolean,
|
||||
): IWidgetData {
|
||||
let perParticipantE2EE = false;
|
||||
if (
|
||||
client.getRoom(roomId)?.hasEncryptionStateEvent() &&
|
||||
!SettingsStore.getValue("feature_disable_call_per_sender_encryption")
|
||||
)
|
||||
perParticipantE2EE = true;
|
||||
|
||||
const intent = ElementCall.getWidgetIntent(client, roomId, voiceOnly);
|
||||
|
||||
return {
|
||||
...currentData,
|
||||
...overwriteData,
|
||||
intent,
|
||||
perParticipantE2EE,
|
||||
perParticipantE2EE:
|
||||
client.getRoom(roomId)?.hasEncryptionStateEvent() &&
|
||||
!SettingsStore.getValue("feature_disable_call_per_sender_encryption"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user