@@ -32,6 +32,7 @@ import classNames from "classnames";
3232import { BehaviorSubject , map } from "rxjs" ;
3333import { useObservable , useObservableEagerState } from "observable-hooks" ;
3434import { logger } from "matrix-js-sdk/lib/logger" ;
35+ import { RoomAndToDeviceEvents } from "matrix-js-sdk/lib/matrixrtc/RoomAndToDeviceKeyTransport" ;
3536
3637import LogoMark from "../icons/LogoMark.svg?react" ;
3738import LogoType from "../icons/LogoType.svg?react" ;
@@ -100,6 +101,8 @@ import {
100101} from "../settings/settings" ;
101102import { ReactionsReader } from "../reactions/ReactionsReader" ;
102103import { ConnectionLostError } from "../utils/errors.ts" ;
104+ import { useTypedEventEmitter } from "../useEvents.ts" ;
105+
103106const canScreenshare = "getDisplayMedia" in ( navigator . mediaDevices ?? { } ) ;
104107
105108const maxTapDurationMs = 400 ;
@@ -217,9 +220,20 @@ export const InCallView: FC<InCallViewProps> = ({
217220 room : livekitRoom ,
218221 } ) ;
219222
220- const [ toDeviceEncryption ] = useSetting (
223+ const [ toDeviceEncryptionSetting ] = useSetting (
221224 useExperimentalToDeviceTransportSetting ,
222225 ) ;
226+ const [ showToDeviceEncryption , setShowToDeviceEncryption ] = useState (
227+ ( ) => toDeviceEncryptionSetting ,
228+ ) ;
229+ useEffect ( ( ) => {
230+ setShowToDeviceEncryption ( toDeviceEncryptionSetting ) ;
231+ } , [ toDeviceEncryptionSetting ] ) ;
232+ useTypedEventEmitter (
233+ rtcSession ,
234+ RoomAndToDeviceEvents . EnabledTransportsChanged ,
235+ ( enabled ) => setShowToDeviceEncryption ( enabled . to_device ) ,
236+ ) ;
223237
224238 const toggleMicrophone = useCallback (
225239 ( ) => muteStates . audio . setEnabled ?.( ( e ) => ! e ) ,
@@ -668,9 +682,9 @@ export const InCallView: FC<InCallViewProps> = ({
668682 </ Header >
669683 ) ) }
670684 {
671- // TODO: remove this once we remove the developer flag
672- // and find a better way to device what key transport to use .
673- toDeviceEncryption && (
685+ // TODO: remove this once we remove the developer flag gets removed and we have shipped to
686+ // device transport as the default .
687+ showToDeviceEncryption && (
674688 < Text
675689 style = { { height : 0 , zIndex : 1 , alignSelf : "center" , margin : 0 } }
676690 size = "sm"
0 commit comments