From 022415e98e4f3a727c4e6bf3aa932f777a106aa5 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Mon, 12 Oct 2026 16:11:03 +0200 Subject: [PATCH] Avoid null in transport dev setting --- src/settings/DeveloperSettingsTab.tsx | 12 ++++++++++-- .../__snapshots__/DeveloperSettingsTab.test.tsx.snap | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/settings/DeveloperSettingsTab.tsx b/src/settings/DeveloperSettingsTab.tsx index 42cc608c7..cd21320e1 100644 --- a/src/settings/DeveloperSettingsTab.tsx +++ b/src/settings/DeveloperSettingsTab.tsx @@ -70,6 +70,7 @@ import { useUrlParams } from "../UrlParams"; import { useBehavior } from "../useBehavior"; import { type ViewModel } from "../state/ViewModel.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. @@ -174,10 +175,10 @@ export const DeveloperSettingsTab: FC = ({ customTransportSetting, ); const [customTransportTextBuffer, setCustomLivekitUrlTextBuffer] = useState( - () => JSON.stringify(customTransport), + () => transportText(customTransport), ); useEffect(() => { - setCustomLivekitUrlTextBuffer(JSON.stringify(customTransport)); + setCustomLivekitUrlTextBuffer(transportText(customTransport)); }, [customTransport]); const [muteAllAudio, setMuteAllAudio] = useSetting(muteAllAudioSetting); @@ -703,3 +704,10 @@ export const DeveloperSettingsTab: FC = ({ ); }; + +/** + * 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); +} diff --git a/src/settings/__snapshots__/DeveloperSettingsTab.test.tsx.snap b/src/settings/__snapshots__/DeveloperSettingsTab.test.tsx.snap index 6bfc9502f..54d1ea478 100644 --- a/src/settings/__snapshots__/DeveloperSettingsTab.test.tsx.snap +++ b/src/settings/__snapshots__/DeveloperSettingsTab.test.tsx.snap @@ -250,7 +250,7 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = ` id="radix-_r_7_" name="input" title="" - value="null" + value="" />