Avoid null in transport dev setting

This commit is contained in:
Johannes Marbach
2026-10-12 16:11:03 +02:00
parent a1575cb554
commit 022415e98e
2 changed files with 11 additions and 3 deletions
+10 -2
View File
@@ -70,6 +70,7 @@ import { useUrlParams } from "../UrlParams";
import { useBehavior } from "../useBehavior"; import { useBehavior } from "../useBehavior";
import { type ViewModel } from "../state/ViewModel.ts"; import { type ViewModel } from "../state/ViewModel.ts";
import { getSFUConfig } from "../livekit/auth/index.ts"; import { getSFUConfig } from "../livekit/auth/index.ts";
import { type UnstableLivekitTransport } from "matrix-js-sdk/lib/matrixrtc";
/** /**
* The state of MatrixRTC's media key rotation. * The state of MatrixRTC's media key rotation.
@@ -174,10 +175,10 @@ export const DeveloperSettingsTab: FC<Props> = ({
customTransportSetting, customTransportSetting,
); );
const [customTransportTextBuffer, setCustomLivekitUrlTextBuffer] = useState( const [customTransportTextBuffer, setCustomLivekitUrlTextBuffer] = useState(
() => JSON.stringify(customTransport), () => transportText(customTransport),
); );
useEffect(() => { useEffect(() => {
setCustomLivekitUrlTextBuffer(JSON.stringify(customTransport)); setCustomLivekitUrlTextBuffer(transportText(customTransport));
}, [customTransport]); }, [customTransport]);
const [muteAllAudio, setMuteAllAudio] = useSetting(muteAllAudioSetting); const [muteAllAudio, setMuteAllAudio] = useSetting(muteAllAudioSetting);
@@ -703,3 +704,10 @@ export const DeveloperSettingsTab: FC<Props> = ({
</> </>
); );
}; };
/**
* The text shown in the custom transport field for a given setting value.
*/
function transportText(transport: UnstableLivekitTransport | null): string {
return transport === null ? "" : JSON.stringify(transport);
}
@@ -250,7 +250,7 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
id="radix-_r_7_" id="radix-_r_7_"
name="input" name="input"
title="" title=""
value="null" value=""
/> />
</div> </div>
<span <span