better attendees
This commit is contained in:
parent
05f3a9062b
commit
2463b323b7
@ -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">
|
||||||
|
@ -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} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user