import { useEffect, useRef, useState } from "react"; import { addChannel } from "../api"; import { BTN, BTN_PRIMARY, Dialog, HELP, INPUT, Spinner } from "./ui"; interface Props { onClose: () => void; onAdded: (title: string) => void; } /** * Adds one channel from a link, for the ones a Takeout export does not have — * something found after the last import, or a channel followed nowhere but * here. Any YouTube link belonging to the channel works, including a video of * theirs, since the channel is what gets read off the page. */ export default function AddChannel({ onClose, onAdded }: Props) { const [url, setUrl] = useState(""); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); const field = useRef(null); useEffect(() => field.current?.focus(), []); const submit = () => { if (busy || !url.trim()) return; setBusy(true); setError(null); addChannel(url.trim()) .then(onAdded) .catch((e) => setError(String(e))) .finally(() => setBusy(false)); }; const footer = (
); return (

Paste any link belonging to the channel — its own page, its @handle, or one of its videos. FlightTube reads the channel from the page and starts following it here. Nothing changes on YouTube.

setUrl(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") submit(); }} placeholder="https://www.youtube.com/@channel" spellCheck={false} className={`${INPUT} mt-3 w-full`} /> {error && (

{error}

)}
); }