diff --git a/src/app/(core)/v/[slug]/loading.tsx b/src/app/(core)/v/[slug]/loading.tsx new file mode 100644 index 0000000..de4c766 --- /dev/null +++ b/src/app/(core)/v/[slug]/loading.tsx @@ -0,0 +1,11 @@ +// Static placeholder in the same layout as the player page (no animation) +export default function Loading() { + return ( +
+
+
+ Loading markers +
+
+ ); +} diff --git a/src/app/(core)/v/[slug]/page.tsx b/src/app/(core)/v/[slug]/page.tsx index a5c2bfd..8cc659e 100644 --- a/src/app/(core)/v/[slug]/page.tsx +++ b/src/app/(core)/v/[slug]/page.tsx @@ -1,34 +1,82 @@ import { auth } from "@clerk/nextjs/server"; -import { - getTwitchTokenFromClerk, - getVodWithMarkers, -} from "~/utils/twitch-server"; +import type { Metadata } from "next"; +import { ButtonLink } from "~/app/_components/common/button"; +import { SignInButton } from "~/app/_components/signin"; +import { EXPORT_BUFFER_SECONDS, MAX_BUFFER_SECONDS } from "~/utils/markers"; +import { getVodWithMarkers } from "~/utils/twitch-server"; import { VodPlayer } from "./player"; -import Script from "next/script"; -export const dynamic = "force-dynamic"; +export const metadata: Metadata = { title: "VOD markers | MarkerThing" }; -// I do the revalidate 0 here because "force-dynamic" doesn't actually work -// See: https://github.com/vercel/next.js/issues/47273 -export const revalidate = 60; +const Notice = (props: { title: string; children: React.ReactNode }) => ( +
+

{props.title}

+ {props.children} +
+); export default async function VodPage({ params, + searchParams, }: { params: Promise<{ slug: string }>; + searchParams: Promise>; }) { - const { slug } = await params; - const self = await auth(); - if (!self || !self.userId) return
You have to be signed in
; + const [{ slug }, query, self] = await Promise.all([ + params, + searchParams, + auth(), + ]); - const token = await getTwitchTokenFromClerk(self.userId); + if (!self.userId) { + return ( + + + + ); + } - const vodDetails = await getVodWithMarkers(slug, token); + const result = await getVodWithMarkers(slug, self.userId); + + if (result.status === "not-found") { + return ( + +

This VOD does not exist, or Twitch deleted it.

+ Go home +
+ ); + } + + if (result.status === "creator-not-connected") { + return ( + +

+ {result.rejected + ? `${result.creator} needs to sign in to MarkerThing again.` + : `${result.creator} has not signed in to MarkerThing yet.`} +

+ Go home +
+ ); + } + + // A repeated param (?offset=1&offset=2) arrives as an array. Use the first. + const param = (key: string) => [query[key]].flat()[0]; + const buffer = Number(param("buffer")); return ( - <> -