"use client"; import { useState, useEffect, useRef } from "react"; import { trpc } from "@/lib/trpc"; import { formatTime, clsx } from "@/lib/utils"; export interface MediaCommentListProps { episodeId: string; assetId: string; assetType?: "audio" | "video" | "transcript"; currentUserId: string; /** Optional seek callback when a comment is clicked. */ onSeek?: (seconds: number) => void; /** Click time of the underlying player. */ currentTime?: number; } /** * A timestamped comment list pinned to an episode asset. Lets editors * / producers drop comments at the exact second of an audio file. * Backed by the tRPC `mediaComments` router (Postgres-backed) plus * the chat panel for the inline message view. */ export function MediaCommentList(props: MediaCommentListProps) { const utils = trpc.useUtils(); const [draft, setDraft] = useState(""); const [draftTime, setDraftTime] = useState(null); const list = trpc.mediaComments.list.useQuery({ episodeId: props.episodeId, assetId: props.assetId, } as any); const create = trpc.mediaComments.create.useMutation({ onSuccess: () => { utils.mediaComments.list.invalidate({ episodeId: props.episodeId, assetId: props.assetId, }); setDraft(""); setDraftTime(null); }, }); const resolve = trpc.mediaComments.resolve.useMutation({ onSuccess: () => { utils.mediaComments.list.invalidate({ episodeId: props.episodeId, assetId: props.assetId, }); }, }); const items = list.data ?? []; return (

Timestamped notes

{items.length} note{items.length === 1 ? "" : "s"}