Read url params for auto leave

This commit is contained in:
Timo
2025-06-27 14:47:45 +02:00
committed by Timo K
parent b523e999a0
commit a180370c50
5 changed files with 27 additions and 6 deletions

View File

@@ -210,6 +210,12 @@ export interface UrlConfiguration {
* Whether and what type of notification EC should send, when the user joins the call. * Whether and what type of notification EC should send, when the user joins the call.
*/ */
sendNotificationType?: RTCNotificationType; sendNotificationType?: RTCNotificationType;
/**
* Whether the app should automatically leave the call when there
* is no one left in the call.
* This is one part to make the call matrixRTC session behave like a telephone call.
*/
telephoneAutoLeave: boolean;
} }
// If you need to add a new flag to this interface, prefer a name that describes // If you need to add a new flag to this interface, prefer a name that describes
@@ -277,10 +283,16 @@ class ParamParser {
]; ];
} }
/**
* Returns true if the flag exists and is not "false".
*/
public getFlagParam(name: string, defaultValue = false): boolean { public getFlagParam(name: string, defaultValue = false): boolean {
const param = this.getParam(name); const param = this.getParam(name);
return param === null ? defaultValue : param !== "false"; return param === null ? defaultValue : param !== "false";
} }
/**
* Returns the value of the flag if it exists, or undefined if it does not.
*/
public getFlag(name: string): boolean | undefined { public getFlag(name: string): boolean | undefined {
const param = this.getParam(name); const param = this.getParam(name);
return param !== null ? param !== "false" : undefined; return param !== null ? param !== "false" : undefined;
@@ -334,6 +346,7 @@ export const getUrlParams = (
skipLobby: true, skipLobby: true,
returnToLobby: false, returnToLobby: false,
sendNotificationType: "notification" as RTCNotificationType, sendNotificationType: "notification" as RTCNotificationType,
telephoneAutoLeave: false,
}; };
switch (intent) { switch (intent) {
case UserIntent.StartNewCall: case UserIntent.StartNewCall:
@@ -377,6 +390,7 @@ export const getUrlParams = (
skipLobby: false, skipLobby: false,
returnToLobby: false, returnToLobby: false,
sendNotificationType: undefined, sendNotificationType: undefined,
telephoneAutoLeave: false,
}; };
} }
@@ -428,12 +442,13 @@ export const getUrlParams = (
"ring", "ring",
"notification", "notification",
]), ]),
telephoneAutoLeave: parser.getFlag("telephoneAutoLeave"),
}; };
return { return {
...properties, ...properties,
...intentPreset, ...intentPreset,
...pickBy(configuration, (v) => v !== undefined), ...pickBy(configuration, (v?: unknown) => v !== undefined),
}; };
}; };

View File

@@ -166,7 +166,11 @@ export const GroupCallView: FC<Props> = ({
const { displayName, avatarUrl } = useProfile(client); const { displayName, avatarUrl } = useProfile(client);
const roomName = useRoomName(room); const roomName = useRoomName(room);
const roomAvatar = useRoomAvatar(room); const roomAvatar = useRoomAvatar(room);
const { perParticipantE2EE, returnToLobby } = useUrlParams(); const {
perParticipantE2EE,
returnToLobby,
password: passwordFromUrl,
} = useUrlParams();
const e2eeSystem = useRoomEncryptionSystem(room.roomId); const e2eeSystem = useRoomEncryptionSystem(room.roomId);
const [useNewMembershipManager] = useSetting(useNewMembershipManagerSetting); const [useNewMembershipManager] = useSetting(useNewMembershipManagerSetting);
const [useExperimentalToDeviceTransport] = useSetting( const [useExperimentalToDeviceTransport] = useSetting(
@@ -174,7 +178,6 @@ export const GroupCallView: FC<Props> = ({
); );
// Save the password once we start the groupCallView // Save the password once we start the groupCallView
const { password: passwordFromUrl } = useUrlParams();
useEffect(() => { useEffect(() => {
if (passwordFromUrl) saveKeyForRoom(room.roomId, passwordFromUrl); if (passwordFromUrl) saveKeyForRoom(room.roomId, passwordFromUrl);
}, [passwordFromUrl, room.roomId]); }, [passwordFromUrl, room.roomId]);

View File

@@ -163,6 +163,8 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
}; };
}, [livekitRoom]); }, [livekitRoom]);
const { telephoneAutoLeave } = useUrlParams();
useEffect(() => { useEffect(() => {
if (livekitRoom !== undefined) { if (livekitRoom !== undefined) {
const reactionsReader = new ReactionsReader(props.rtcSession); const reactionsReader = new ReactionsReader(props.rtcSession);
@@ -172,7 +174,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
mediaDevices, mediaDevices,
{ {
encryptionSystem: props.e2eeSystem, encryptionSystem: props.e2eeSystem,
autoLeaveWhenOthersLeft: undefined, autoLeaveWhenOthersLeft: telephoneAutoLeave,
}, },
connStateObservable$, connStateObservable$,
reactionsReader.raisedHands$, reactionsReader.raisedHands$,
@@ -190,6 +192,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
mediaDevices, mediaDevices,
props.e2eeSystem, props.e2eeSystem,
connStateObservable$, connStateObservable$,
telephoneAutoLeave,
]); ]);
if (livekitRoom === undefined || vm === null) return null; if (livekitRoom === undefined || vm === null) return null;

View File

@@ -282,7 +282,7 @@ function withCallViewModel(
liveKitRoom, liveKitRoom,
mediaDevices, mediaDevices,
{ {
kind: E2eeType.PER_PARTICIPANT, encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
}, },
connectionState$, connectionState$,
raisedHands$, raisedHands$,

View File

@@ -139,7 +139,7 @@ export function getBasicCallViewModelEnvironment(
liveKitRoom, liveKitRoom,
mockMediaDevices({}), mockMediaDevices({}),
{ {
kind: E2eeType.PER_PARTICIPANT, encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
}, },
of(ConnectionState.Connected), of(ConnectionState.Connected),
handRaisedSubject$, handRaisedSubject$,