Make E2EEConfig required
Previously it could be either undefined or type None which meant the same thing: no need to have both, just make it required. This also means we can move the line to set e2ee enabled into a more sensible place rather than in the ActiveCall de-nulling wrapper.
This commit is contained in:
@@ -56,11 +56,11 @@ interface UseLivekitResult {
|
|||||||
export function useLiveKit(
|
export function useLiveKit(
|
||||||
rtcSession: MatrixRTCSession,
|
rtcSession: MatrixRTCSession,
|
||||||
muteStates: MuteStates,
|
muteStates: MuteStates,
|
||||||
sfuConfig?: SFUConfig,
|
sfuConfig: SFUConfig | undefined,
|
||||||
e2eeConfig?: E2EEConfig,
|
e2eeConfig: E2EEConfig,
|
||||||
): UseLivekitResult {
|
): UseLivekitResult {
|
||||||
const e2eeOptions = useMemo((): E2EEOptions | undefined => {
|
const e2eeOptions = useMemo((): E2EEOptions | undefined => {
|
||||||
if (!e2eeConfig || e2eeConfig.mode === E2eeType.NONE) return undefined;
|
if (e2eeConfig.mode === E2eeType.NONE) return undefined;
|
||||||
|
|
||||||
if (e2eeConfig.mode === E2eeType.PER_PARTICIPANT) {
|
if (e2eeConfig.mode === E2eeType.PER_PARTICIPANT) {
|
||||||
return {
|
return {
|
||||||
@@ -79,7 +79,7 @@ export function useLiveKit(
|
|||||||
}, [e2eeConfig]);
|
}, [e2eeConfig]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!e2eeConfig || !e2eeOptions) return;
|
if (e2eeConfig.mode === E2eeType.NONE || !e2eeOptions) return;
|
||||||
|
|
||||||
if (e2eeConfig.mode === E2eeType.PER_PARTICIPANT) {
|
if (e2eeConfig.mode === E2eeType.PER_PARTICIPANT) {
|
||||||
(e2eeOptions.keyProvider as MatrixKeyProvider).setRTCSession(rtcSession);
|
(e2eeOptions.keyProvider as MatrixKeyProvider).setRTCSession(rtcSession);
|
||||||
@@ -137,7 +137,11 @@ export function useLiveKit(
|
|||||||
// We have to create the room manually here due to a bug inside
|
// We have to create the room manually here due to a bug inside
|
||||||
// @livekit/components-react. JSON.stringify() is used in deps of a
|
// @livekit/components-react. JSON.stringify() is used in deps of a
|
||||||
// useEffect() with an argument that references itself, if E2EE is enabled
|
// useEffect() with an argument that references itself, if E2EE is enabled
|
||||||
const roomWithoutProps = useMemo(() => new Room(roomOptions), [roomOptions]);
|
const roomWithoutProps = useMemo(() => {
|
||||||
|
const r = new Room(roomOptions);
|
||||||
|
r.setE2EEEnabled(e2eeConfig.mode !== E2eeType.NONE);
|
||||||
|
return r;
|
||||||
|
}, [roomOptions, e2eeConfig]);
|
||||||
const { room } = useLiveKitRoom({
|
const { room } = useLiveKitRoom({
|
||||||
token: sfuConfig?.jwt,
|
token: sfuConfig?.jwt,
|
||||||
serverUrl: sfuConfig?.url,
|
serverUrl: sfuConfig?.url,
|
||||||
|
|||||||
@@ -249,11 +249,13 @@ export const GroupCallView: FC<Props> = ({
|
|||||||
}
|
}
|
||||||
}, [isJoined, rtcSession]);
|
}, [isJoined, rtcSession]);
|
||||||
|
|
||||||
const e2eeConfig = useMemo((): E2EEConfig | undefined => {
|
const e2eeConfig = useMemo((): E2EEConfig => {
|
||||||
if (perParticipantE2EE) {
|
if (perParticipantE2EE) {
|
||||||
return { mode: E2eeType.PER_PARTICIPANT };
|
return { mode: E2eeType.PER_PARTICIPANT };
|
||||||
} else if (e2eeSharedKey) {
|
} else if (e2eeSharedKey) {
|
||||||
return { mode: E2eeType.SHARED_KEY, sharedKey: e2eeSharedKey };
|
return { mode: E2eeType.SHARED_KEY, sharedKey: e2eeSharedKey };
|
||||||
|
} else {
|
||||||
|
return { mode: E2eeType.NONE };
|
||||||
}
|
}
|
||||||
}, [perParticipantE2EE, e2eeSharedKey]);
|
}, [perParticipantE2EE, e2eeSharedKey]);
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ const POST_FOCUS_PARTICIPANT_UPDATE_DELAY_MS = 3000;
|
|||||||
|
|
||||||
export interface ActiveCallProps
|
export interface ActiveCallProps
|
||||||
extends Omit<InCallViewProps, "livekitRoom" | "connState"> {
|
extends Omit<InCallViewProps, "livekitRoom" | "connState"> {
|
||||||
e2eeConfig?: E2EEConfig;
|
e2eeConfig: E2EEConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
||||||
@@ -111,10 +111,6 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.e2eeConfig && !livekitRoom.isE2EEEnabled) {
|
|
||||||
livekitRoom.setE2EEEnabled(!!props.e2eeConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RoomContext.Provider value={livekitRoom}>
|
<RoomContext.Provider value={livekitRoom}>
|
||||||
<InCallView {...props} livekitRoom={livekitRoom} connState={connState} />
|
<InCallView {...props} livekitRoom={livekitRoom} connState={connState} />
|
||||||
|
|||||||
Reference in New Issue
Block a user