xonecas.io
4828
Sr

stream-together / commit 48c7a4f

Adds an easy way to copy and send the hosts url

sean2024-06-27 48c7a4fef53c1a7ea8c6fbdf83b406a0c00ee57f parent 36114d2

3 files changed

app/[slug]/host/page.tsx+30−1
@@ -1,7 +1,10 @@
11 "use client";
22
33 import dynamic from "next/dynamic";
4-import { useLocalStorage } from "usehooks-ts";
4+import { useCallback, useEffect, useState } from "react";
5+import { FaRegCopy as CopyIcon } from "react-icons/fa";
6+import { IoMdCheckmark as CheckmarkIcon } from "react-icons/io";
7+import { useCopyToClipboard, useLocalStorage } from "usehooks-ts";
58
69 const AgoraProvider = dynamic(() => import("@/components/agora-provider"), {
710 ssr: false,
@@ -19,10 +22,36 @@ export default function StreamSetupPage({
1922 const [appId] = useLocalStorage("app-id", "");
2023 const [token] = useLocalStorage("token", "");
2124 const [channel] = useLocalStorage("channel", "");
25+ const [currentUrl, setCurrentUrl] = useState("");
26+ const [copied, copy] = useCopyToClipboard();
27+
28+ useEffect(() => {
29+ if (typeof window !== "undefined") {
30+ setCurrentUrl(window.location.href);
31+ }
32+ }, []);
2233
2334 return (
2435 <AgoraProvider>
2536 <div className="flex flex-col items-center gap-16">
37+ <div className="w-1/2 text-center">
38+ <p className="text-lg p-2">
39+ Share this url with your co-host for them to join you!
40+ </p>
41+
42+ <button
43+ className="flex flex-row justify-between bg-stone-600 p-4 rounded-xl w-full"
44+ onClick={() => copy(currentUrl)}
45+ >
46+ <pre className="">{currentUrl}</pre>
47+ {copied === currentUrl ? (
48+ <CheckmarkIcon size="1.25em" />
49+ ) : (
50+ <CopyIcon size="1.25em" />
51+ )}
52+ </button>
53+ </div>
54+
2655 <AgoraHost config={{ appId, channel, token }} />
2756 </div>
2857 </AgoraProvider>
app/new/page.tsx+4−2
@@ -34,7 +34,7 @@ export default function NewStreamPage() {
3434 if (!appId || !token || !channel) setError("All fields are required.");
3535 else {
3636 const slug = slugify(channel);
37- router.push("/" + slug);
37+ router.push("/" + slug + "/host");
3838 }
3939 }, [appId, token, channel, router]);
4040
@@ -93,7 +93,9 @@ export default function NewStreamPage() {
9393
9494 <div className="w-1/2 flex flex-col gap-4">
9595 <button onClick={handleNextClick}>
96- <PrimaryButton>Next</PrimaryButton>
96+ <PrimaryButton>
97+ <p className="px-4 py-2">Next</p>
98+ </PrimaryButton>
9799 </button>
98100 {error && <p className="text-rose-600">{error}</p>}
99101 </div>
app/page.tsx+4−1
@@ -1,4 +1,5 @@
11 import Link from "next/link";
2+
23 import Logo from "../components/logo";
34 import PrimaryButton from "../components/primary-button";
45
@@ -7,7 +8,9 @@ export default function Home() {
78 <main className="flex min-h-screen flex-col items-center justify-start p-8 gap-20">
89 <Logo />
910 <Link href="/new">
10- <PrimaryButton>Go live now!</PrimaryButton>
11+ <PrimaryButton>
12+ <p className="px-4 py-2 text-2xl">Go live now!</p>
13+ </PrimaryButton>
1114 </Link>
1215 </main>
1316 );