Hangup when last person in call (based on url params) (#3372)

* Introduce condigurable auto leave option

* Read url params for auto leave

* add tests

* rename url param to `autoLeave`

* lint

Signed-off-by: Timo K <toger5@hotmail.de>

* fix scope in CallViewModel tests

Signed-off-by: Timo K <toger5@hotmail.de>

* use auto leave in DM case

Signed-off-by: Timo K <toger5@hotmail.de>

* Make last once leave logic based on matrix user id (was participant id before)

Signed-off-by: Timo K <toger5@hotmail.de>

* add test for multi device auto leave

Signed-off-by: Timo K <toger5@hotmail.de>

---------

Signed-off-by: Timo K <toger5@hotmail.de>
This commit is contained in:
Timo
2025-08-08 17:15:47 +02:00
committed by GitHub
parent 6667fc54c0
commit a733461845
9 changed files with 339 additions and 70 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.
*/
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.
*/
autoLeaveWhenOthersLeft: boolean;
}
// 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 {
const param = this.getParam(name);
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 {
const param = this.getParam(name);
return param !== null ? param !== "false" : undefined;
@@ -334,6 +346,7 @@ export const getUrlParams = (
skipLobby: true,
returnToLobby: false,
sendNotificationType: "notification" as RTCNotificationType,
autoLeaveWhenOthersLeft: false,
};
switch (intent) {
case UserIntent.StartNewCall:
@@ -352,14 +365,14 @@ export const getUrlParams = (
intentPreset = {
...inAppDefault,
skipLobby: true,
// autoLeaveWhenOthersLeft: true, // TODO: add this once available
autoLeaveWhenOthersLeft: true,
};
break;
case UserIntent.JoinExistingCallDM:
intentPreset = {
...inAppDefault,
skipLobby: true,
// autoLeaveWhenOthersLeft: true, // TODO: add this once available
autoLeaveWhenOthersLeft: true,
};
break;
// Non widget usecase defaults
@@ -377,6 +390,7 @@ export const getUrlParams = (
skipLobby: false,
returnToLobby: false,
sendNotificationType: undefined,
autoLeaveWhenOthersLeft: false,
};
}
@@ -428,12 +442,13 @@ export const getUrlParams = (
"ring",
"notification",
]),
autoLeaveWhenOthersLeft: parser.getFlag("autoLeave"),
};
return {
...properties,
...intentPreset,
...pickBy(configuration, (v) => v !== undefined),
...pickBy(configuration, (v?: unknown) => v !== undefined),
};
};