Skip to content

Commit 81864fe

Browse files
committed
Read url params for auto leave
1 parent b036bb4 commit 81864fe

File tree

5 files changed

+20
-5
lines changed

5 files changed

+20
-5
lines changed

src/UrlParams.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ export interface UrlParams {
7171
* is window.controls.onBackButtonPressed.
7272
*/
7373
header: HeaderStyle;
74+
/**
75+
* If we want the app to automatically leave the call when all other participants
76+
* leave the call.
77+
*
78+
* This is used in settings where EC should behave more like a phone call other than a conference.
79+
* Like in a DM.
80+
*/
81+
telephoneAutoLeave: boolean;
7482
/**
7583
* Whether the controls should be shown. For screen recording no controls can be desired.
7684
*/
@@ -329,6 +337,7 @@ export const getUrlParams = (
329337
rageshakeSubmitUrl: parser.getParam("rageshakeSubmitUrl"),
330338
sentryDsn: parser.getParam("sentryDsn"),
331339
sentryEnvironment: parser.getParam("sentryEnvironment"),
340+
telephoneAutoLeave: parser.getFlagParam("telephoneAutoLeave"),
332341
};
333342
};
334343

src/room/GroupCallView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,18 @@ export const GroupCallView: FC<Props> = ({
166166
const { displayName, avatarUrl } = useProfile(client);
167167
const roomName = useRoomName(room);
168168
const roomAvatar = useRoomAvatar(room);
169-
const { perParticipantE2EE, returnToLobby } = useUrlParams();
169+
const {
170+
perParticipantE2EE,
171+
returnToLobby,
172+
password: passwordFromUrl,
173+
} = useUrlParams();
170174
const e2eeSystem = useRoomEncryptionSystem(room.roomId);
171175
const [useNewMembershipManager] = useSetting(useNewMembershipManagerSetting);
172176
const [useExperimentalToDeviceTransport] = useSetting(
173177
useExperimentalToDeviceTransportSetting,
174178
);
175179

176180
// Save the password once we start the groupCallView
177-
const { password: passwordFromUrl } = useUrlParams();
178181
useEffect(() => {
179182
if (passwordFromUrl) saveKeyForRoom(room.roomId, passwordFromUrl);
180183
}, [passwordFromUrl, room.roomId]);

src/room/InCallView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
162162
};
163163
}, [livekitRoom]);
164164

165+
const { telephoneAutoLeave } = useUrlParams();
166+
165167
useEffect(() => {
166168
if (livekitRoom !== undefined) {
167169
const reactionsReader = new ReactionsReader(props.rtcSession);
@@ -171,7 +173,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
171173
mediaDevices,
172174
{
173175
encryptionSystem: props.e2eeSystem,
174-
autoLeaveWhenOthersLeft: undefined,
176+
autoLeaveWhenOthersLeft: telephoneAutoLeave,
175177
},
176178
connStateObservable$,
177179
reactionsReader.raisedHands$,
@@ -189,6 +191,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
189191
mediaDevices,
190192
props.e2eeSystem,
191193
connStateObservable$,
194+
telephoneAutoLeave,
192195
]);
193196

194197
if (livekitRoom === undefined || vm === null) return null;

src/state/CallViewModel.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ function withCallViewModel(
272272
liveKitRoom,
273273
mediaDevices,
274274
{
275-
kind: E2eeType.PER_PARTICIPANT,
275+
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
276276
},
277277
connectionState$,
278278
raisedHands$,

src/utils/test-viewmodel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function getBasicCallViewModelEnvironment(
139139
liveKitRoom,
140140
mockMediaDevices({}),
141141
{
142-
kind: E2eeType.PER_PARTICIPANT,
142+
encryptionSystem: { kind: E2eeType.PER_PARTICIPANT },
143143
},
144144
of(ConnectionState.Connected),
145145
handRaisedSubject$,

0 commit comments

Comments
 (0)