mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Read url params for auto leave
This commit is contained in:
@@ -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),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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]);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ function withCallViewModel(
|
|||||||
liveKitRoom,
|
liveKitRoom,
|
||||||
mediaDevices,
|
mediaDevices,
|
||||||
{
|
{
|
||||||
kind: E2eeType.PER_PARTICIPANT,
|
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
|
||||||
},
|
},
|
||||||
connectionState$,
|
connectionState$,
|
||||||
raisedHands$,
|
raisedHands$,
|
||||||
|
|||||||
@@ -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$,
|
||||||
|
|||||||
Reference in New Issue
Block a user