import { useEffect, useId, useRef, useState } from "react"; import { useAnchoredPopover } from "../../components/living/use-anchored-popover"; import { Tooltip } from "../../components/living/Tooltip"; import { Glyph } from "../../ui/icons"; import { useCopy } from "../../ui/copy"; import type { ChannelController } from "../types"; import { ChannelAction } from "./ChannelMedia"; import { ChannelIdentityFields } from "./ChannelIdentity"; import "./channel-name-editor.css"; import "./channel-room-controls.css"; export function ChannelDomainControls({ channel }: { channel: ChannelController }) { const { lang, vis } = useCopy(); const zh = lang === "zh"; const current = channel.state!.channel; const id = useId(); const trigger = useRef(null); const panel = useRef(null); const [name, setName] = useState(current.name); const [icon, setIcon] = useState(current.icon); const [open, setOpen] = useState(false); const [imageBusy, setImageBusy] = useState(false); const busy = channel.pending.has("domain"); const disabled = channel.connection !== "connected" || busy; const title = zh ? "域外观" : "Domain appearance"; useAnchoredPopover(trigger, panel, { side: "below", align: "end" }); useEffect(() => { if (open) { const input = panel.current?.querySelector("input"); input?.focus({ preventScroll: true }); input?.select(); } }, [open]); return <> ; }