"use client"; import { Section, SectionHeader, SectionTitle, SectionContent, } from "@/containers/PageSection"; import LiveBadge from "@/components/Badges/LiveBadge"; import { Button } from "@/components/ui/button"; import { RiArrowRightLine } from "react-icons/ri"; import VideoCard, { VideoCardLoading } from "@/components/VideoCard"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import Link from "next/link"; import useEvents from "@/lib/hooks/useEvents"; import { Event } from "nostr-tools"; import KindLoading from "@/components/KindCard/loading"; import { nip19 } from "nostr-tools"; import { getTagValues, getTagsValues } from "@/lib/nostr/utils"; import { NOTABLE_ACCOUNTS } from "@/constants"; import { type NDKKind } from "@nostr-dev-kit/ndk"; import { uniqBy } from "ramda"; export default function LiveStreamingSection() { const { events } = useEvents({ filter: { kinds: [30311 as NDKKind], limit: 5, }, }); const processedEvents = uniqBy( (e) => getTagValues("title", e.tags), events, ).sort((a, b) => { const aParticipants = getTagValues("total_participants", a.tags) ?? getTagValues("current_participants", a.tags); const bParticipants = getTagValues("total_participants", b.tags) ?? getTagValues("current_participants", b.tags); if (aParticipants && bParticipants) { if (parseInt(aParticipants) < parseInt(bParticipants)) { return 1; } else return -1; } if (bParticipants) return 1; return -1; }); return (
Streaming Now
{processedEvents?.length > 3 ? ( processedEvents .filter((e) => !!getTagValues("summary", e.tags)) .slice(0, 6) .map((e, idx) => { const event = e.rawEvent() as Event; const image = getTagValues("image", event.tags) as string; const title = getTagValues("title", event.tags) as string; const starts = getTagValues("starts", event.tags) as string; const ends = getTagValues("ends", event.tags) as string; const tags = getTagsValues("t", event.tags) as string[]; const total_participants = getTagValues("total_participants", event.tags) ?? (getTagValues( "current_participants", event.tags, ) as string); const status = getTagValues("status", event.tags) as | "live" | "planned" | "ended"; return ( ); }) ) : ( <> )}
); }