mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-05 19:59:20 +00:00
only allow skip lobby in widget (more strict needs test adjustment)
This commit is contained in:
@@ -23,6 +23,7 @@ interface RoomIdentifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum UserIntent {
|
export enum UserIntent {
|
||||||
|
// TODO: add DM vs room call
|
||||||
StartNewCall = "start_call",
|
StartNewCall = "start_call",
|
||||||
JoinExistingCall = "join_existing",
|
JoinExistingCall = "join_existing",
|
||||||
Unknown = "unknown",
|
Unknown = "unknown",
|
||||||
@@ -299,6 +300,10 @@ export const getUrlParams = (
|
|||||||
|
|
||||||
const fontScale = parseFloat(parser.getParam("fontScale") ?? "");
|
const fontScale = parseFloat(parser.getParam("fontScale") ?? "");
|
||||||
|
|
||||||
|
const widgetId = parser.getParam("widgetId");
|
||||||
|
const parentUrl = parser.getParam("parentUrl");
|
||||||
|
const isWidget = !!widgetId && !!parentUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user's intent with respect to the call.
|
* The user's intent with respect to the call.
|
||||||
* e.g. if they clicked a Start Call button, this would be `start_call`.
|
* e.g. if they clicked a Start Call button, this would be `start_call`.
|
||||||
@@ -310,9 +315,9 @@ export const getUrlParams = (
|
|||||||
* In short: either provide url query parameters of UrlConfiguration or set the intent
|
* In short: either provide url query parameters of UrlConfiguration or set the intent
|
||||||
* (or the global defaults will be used).
|
* (or the global defaults will be used).
|
||||||
*/
|
*/
|
||||||
const intent =
|
const intent = !isWidget
|
||||||
parser.getEnumParam("intent", UserIntent) ?? UserIntent.Unknown;
|
? UserIntent.Unknown
|
||||||
|
: (parser.getEnumParam("intent", UserIntent) ?? UserIntent.Unknown);
|
||||||
// Here we only use constants and `platform` to determine the intent preset.
|
// Here we only use constants and `platform` to determine the intent preset.
|
||||||
let intentPreset: UrlConfiguration;
|
let intentPreset: UrlConfiguration;
|
||||||
switch (intent) {
|
switch (intent) {
|
||||||
@@ -329,6 +334,7 @@ export const getUrlParams = (
|
|||||||
controlledAudioDevices: platform === "desktop" ? false : true,
|
controlledAudioDevices: platform === "desktop" ? false : true,
|
||||||
skipLobby: true,
|
skipLobby: true,
|
||||||
returnToLobby: false,
|
returnToLobby: false,
|
||||||
|
sendNotificationType: "notification",
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case UserIntent.JoinExistingCall:
|
case UserIntent.JoinExistingCall:
|
||||||
@@ -344,8 +350,10 @@ export const getUrlParams = (
|
|||||||
controlledAudioDevices: platform === "desktop" ? false : true,
|
controlledAudioDevices: platform === "desktop" ? false : true,
|
||||||
skipLobby: false,
|
skipLobby: false,
|
||||||
returnToLobby: false,
|
returnToLobby: false,
|
||||||
|
sendNotificationType: undefined,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
// Non widget usecase defaults
|
||||||
default:
|
default:
|
||||||
intentPreset = {
|
intentPreset = {
|
||||||
confineToRoom: false,
|
confineToRoom: false,
|
||||||
@@ -359,17 +367,10 @@ export const getUrlParams = (
|
|||||||
controlledAudioDevices: false,
|
controlledAudioDevices: false,
|
||||||
skipLobby: false,
|
skipLobby: false,
|
||||||
returnToLobby: false,
|
returnToLobby: false,
|
||||||
|
sendNotificationType: undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const sendNotificationType = ["ring", "notification"].includes(
|
|
||||||
parser.getParam("sendNotificationType") ?? "",
|
|
||||||
)
|
|
||||||
? (parser.getParam("sendNotificationType") as RTCNotificationType)
|
|
||||||
: undefined;
|
|
||||||
const widgetId = parser.getParam("widgetId");
|
|
||||||
const parentUrl = parser.getParam("parentUrl");
|
|
||||||
const isWidget = !!widgetId && !!parentUrl;
|
|
||||||
const properties: UrlProperties = {
|
const properties: UrlProperties = {
|
||||||
widgetId,
|
widgetId,
|
||||||
parentUrl,
|
parentUrl,
|
||||||
@@ -414,7 +415,10 @@ export const getUrlParams = (
|
|||||||
// In SPA mode the user should always exit to the home screen when hanging
|
// In SPA mode the user should always exit to the home screen when hanging
|
||||||
// up, rather than being sent back to the lobby
|
// up, rather than being sent back to the lobby
|
||||||
returnToLobby: isWidget ? parser.getFlag("returnToLobby") : false,
|
returnToLobby: isWidget ? parser.getFlag("returnToLobby") : false,
|
||||||
sendNotificationType,
|
sendNotificationType: parser.getEnumParam("sendNotificationType", [
|
||||||
|
"ring",
|
||||||
|
"notification",
|
||||||
|
]),
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -191,7 +191,11 @@ describe("useMuteStates", () => {
|
|||||||
mockConfig();
|
mockConfig();
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<MemoryRouter initialEntries={["/room/?skipLobby=true"]}>
|
<MemoryRouter
|
||||||
|
initialEntries={[
|
||||||
|
"/room/?skipLobby=true&widgetId=1234&parentUrl=www.parent.org",
|
||||||
|
]}
|
||||||
|
>
|
||||||
<MediaDevicesContext value={mockMediaDevices()}>
|
<MediaDevicesContext value={mockMediaDevices()}>
|
||||||
<TestComponent />
|
<TestComponent />
|
||||||
</MediaDevicesContext>
|
</MediaDevicesContext>
|
||||||
|
|||||||
Reference in New Issue
Block a user