import { Dispatch, SetStateAction, useCallback } from "react"; import { Button } from "@/components/buttons/Button"; import { Toggle } from "@/components/buttons/Toggle"; import { Icon, Icons } from "@/components/Icon"; import { SettingsCard } from "@/components/layout/SettingsCard"; import { AuthInputBox } from "@/components/text-inputs/AuthInputBox"; import { Divider } from "@/components/utils/Divider"; import { Heading1 } from "@/components/utils/Text"; interface ProxyEditProps { proxyUrls: string[] | null; setProxyUrls: Dispatch>; } interface BackendEditProps { backendUrl: string | null; setBackendUrl: Dispatch>; } function ProxyEdit({ proxyUrls, setProxyUrls }: ProxyEditProps) { const add = useCallback(() => { setProxyUrls((s) => [...(s ?? []), ""]); }, [setProxyUrls]); const changeItem = useCallback( (index: number, val: string) => { setProxyUrls((s) => [ ...(s ?? []).map((v, i) => { if (i !== index) return v; return val; }), ]); }, [setProxyUrls] ); const removeItem = useCallback( (index: number) => { setProxyUrls((s) => [...(s ?? []).filter((v, i) => i !== index)]); }, [setProxyUrls] ); return (

Use custom proxy workers

To make the application function, all traffic is routed through proxies. Enable this if you want to bring your own workers.

setProxyUrls((s) => (s === null ? [] : null))} enabled={proxyUrls !== null} />
{proxyUrls !== null ? ( <>

Worker URLs

{(proxyUrls?.length ?? 0) === 0 ? (

No workers yet, add one below

) : null} {(proxyUrls ?? []).map((v, i) => (
changeItem(i, val)} placeholder="https://" />
))}
) : null}
); } function BackendEdit({ backendUrl, setBackendUrl }: BackendEditProps) { return (

Custom server

To make the application function, all traffic is routed through proxies. Enable this if you want to bring your own workers.

setBackendUrl((s) => (s === null ? "" : null))} enabled={backendUrl !== null} />
{backendUrl !== null ? ( <>

Custom server URL

) : null}
); } export function ConnectionsPart(props: BackendEditProps & ProxyEditProps) { return (
Connections
); }