better attendees

This commit is contained in:
zmeyer44 2023-11-13 19:38:09 -05:00
parent 05f3a9062b
commit 2463b323b7
2 changed files with 29 additions and 4 deletions

View File

@ -1,13 +1,35 @@
"use client";
import { useEffect, useState } from "react";
import { HiOutlineUserGroup } from "react-icons/hi2"; import { HiOutlineUserGroup } from "react-icons/hi2";
import AvatarStack from "@/components/ProfileContainers/AvatarStack"; import AvatarStack from "@/components/ProfileContainers/AvatarStack";
import useEvents from "@/lib/hooks/useEvents";
import UserRow from "./UserRow"; import { NDKKind } from "@nostr-dev-kit/ndk";
import { getTagValues, getTagAllValues } from "@/lib/nostr/utils";
import { removeDuplicates } from "@/lib/utils";
type AttendeesContainerProps = { type AttendeesContainerProps = {
attendees: string[]; attendees: string[];
eventReference: string;
}; };
export default function AttendeesContainer({ export default function AttendeesContainer({
attendees, attendees: _attendees,
eventReference,
}: AttendeesContainerProps) { }: AttendeesContainerProps) {
const [attendees, setAttendees] = useState(_attendees);
const { events } = useEvents({
filter: {
kinds: [31925 as NDKKind],
["#a"]: [eventReference],
},
});
useEffect(() => {
const users = events
.filter((e) => getTagAllValues("l", e.tags).includes("accepted"))
.map((e) => e.pubkey);
setAttendees(removeDuplicates([..._attendees, ...users]));
}, [events]);
return ( return (
<div className="overflow-hidden rounded-[1rem] border bg-muted p-[0.5rem]"> <div className="overflow-hidden rounded-[1rem] border bg-muted p-[0.5rem]">
<div className="flex items-center gap-x-3 px-2 pb-2"> <div className="flex items-center gap-x-3 px-2 pb-2">

View File

@ -93,7 +93,10 @@ export default function EventPage({
/> />
)} )}
<HostsContainer hosts={hosts} /> <HostsContainer hosts={hosts} />
<AttendeesContainer attendees={attendees} /> <AttendeesContainer
attendees={attendees}
eventReference={eventTagId}
/>
</div> </div>
<div className="max-w-2xl grow space-y-4"> <div className="max-w-2xl grow space-y-4">
<AnnouncementsContainer eventReference={eventTagId} hosts={hosts} /> <AnnouncementsContainer eventReference={eventTagId} hosts={hosts} />