This commit is contained in:
Timo K
2025-12-11 18:00:23 +01:00
parent c20b206ab2
commit df2f503a05
3 changed files with 11 additions and 17 deletions

View File

@@ -79,6 +79,7 @@ describe("DeveloperSettingsTab", () => {
const { container } = render( const { container } = render(
<DeveloperSettingsTab <DeveloperSettingsTab
client={client} client={client}
roomId={"#room:example.org"}
livekitRooms={livekitRooms} livekitRooms={livekitRooms}
env={{ MY_MOCK_ENV: 10, ENV: "test" } as unknown as ImportMetaEnv} env={{ MY_MOCK_ENV: 10, ENV: "test" } as unknown as ImportMetaEnv}
/>, />,

View File

@@ -22,13 +22,13 @@ import {
import { logger } from "matrix-js-sdk/lib/logger"; import { logger } from "matrix-js-sdk/lib/logger";
import { import {
EditInPlace, EditInPlace,
ErrorMessage,
Root as Form, Root as Form,
Heading, Heading,
HelpMessage, HelpMessage,
InlineField, InlineField,
Label, Label,
RadioControl, RadioControl,
Text,
} from "@vector-im/compound-web"; } from "@vector-im/compound-web";
import { FieldRow, InputField } from "../input/Input"; import { FieldRow, InputField } from "../input/Input";
@@ -50,6 +50,7 @@ import { getSFUConfigWithOpenID } from "../livekit/openIDSFU";
interface Props { interface Props {
client: MatrixClient; client: MatrixClient;
roomId: string;
livekitRooms?: { room: LivekitRoom; url: string; isLocal?: boolean }[]; livekitRooms?: { room: LivekitRoom; url: string; isLocal?: boolean }[];
env: ImportMetaEnv; env: ImportMetaEnv;
} }
@@ -57,6 +58,7 @@ interface Props {
export const DeveloperSettingsTab: FC<Props> = ({ export const DeveloperSettingsTab: FC<Props> = ({
client, client,
livekitRooms, livekitRooms,
roomId,
env, env,
}) => { }) => {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -221,7 +223,6 @@ export const DeveloperSettingsTab: FC<Props> = ({
/>{" "} />{" "}
</FieldRow> </FieldRow>
<EditInPlace <EditInPlace
serverInvalid={customLivekitUrlUpdateError !== null}
onSubmit={(e) => e.preventDefault()} onSubmit={(e) => e.preventDefault()}
helpLabel={ helpLabel={
customLivekitUrl === null customLivekitUrl === null
@@ -240,30 +241,22 @@ export const DeveloperSettingsTab: FC<Props> = ({
customLivekitUrlTextBuffer === null customLivekitUrlTextBuffer === null
) { ) {
setCustomLivekitUrl(null); setCustomLivekitUrl(null);
return Promise.resolve(); return;
} }
try { try {
logger.debug("try setting");
await getSFUConfigWithOpenID( await getSFUConfigWithOpenID(
client, client,
customLivekitUrlTextBuffer, customLivekitUrlTextBuffer,
"Test-room-alias-" + Date.now().toString() + client.getUserId(), roomId,
); );
logger.debug("done setting! Success");
setCustomLivekitUrlUpdateError(null); setCustomLivekitUrlUpdateError(null);
setCustomLivekitUrl(customLivekitUrlTextBuffer); setCustomLivekitUrl(customLivekitUrlTextBuffer);
} catch (e) { } catch {
logger.error("failed setting", e);
setCustomLivekitUrlUpdateError("invalid URL (did not update)"); setCustomLivekitUrlUpdateError("invalid URL (did not update)");
// automatically unset the error after 4 seconds (2 seconds will be for the save label)
setTimeout(() => {
logger.debug("unsetting error");
setCustomLivekitUrlUpdateError(null);
}, 2000);
} }
}, },
[customLivekitUrlTextBuffer, setCustomLivekitUrl, client], [customLivekitUrlTextBuffer, setCustomLivekitUrl, client, roomId],
)} )}
value={customLivekitUrlTextBuffer ?? ""} value={customLivekitUrlTextBuffer ?? ""}
onChange={useCallback( onChange={useCallback(
@@ -278,11 +271,10 @@ export const DeveloperSettingsTab: FC<Props> = ({
}, },
[setCustomLivekitUrl], [setCustomLivekitUrl],
)} )}
serverInvalid={customLivekitUrlUpdateError !== null}
> >
{customLivekitUrlUpdateError !== null && ( {customLivekitUrlUpdateError !== null && (
<Text size="sm" priority="low"> <ErrorMessage>{customLivekitUrlUpdateError}</ErrorMessage>
{customLivekitUrlUpdateError}
</Text>
)} )}
</EditInPlace> </EditInPlace>
<Heading as="h3" type="body" weight="semibold" size="lg"> <Heading as="h3" type="body" weight="semibold" size="lg">

View File

@@ -213,6 +213,7 @@ export const SettingsModal: FC<Props> = ({
env={import.meta.env} env={import.meta.env}
client={client} client={client}
livekitRooms={livekitRooms} livekitRooms={livekitRooms}
roomId={roomId}
/> />
), ),
}; };