sorting my participants

This commit is contained in:
zmeyer44 2023-10-16 11:23:37 -04:00
parent 2e8a389a22
commit a7f954a63d
5 changed files with 50 additions and 11 deletions

View File

@ -29,8 +29,25 @@ export default function LiveStreamingSection() {
}, },
}); });
const processedEvents = uniqBy((e) => getTagValues("title", e.tags), events); const processedEvents = uniqBy(
console.log(events); (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;
});
console.log(processedEvents);
return ( return (
<Section className="max-sm:-mx-5"> <Section className="max-sm:-mx-5">
<SectionHeader> <SectionHeader>
@ -55,6 +72,7 @@ export default function LiveStreamingSection() {
const image = getTagValues("image", event.tags) as string; const image = getTagValues("image", event.tags) as string;
const title = getTagValues("title", event.tags) as string; const title = getTagValues("title", event.tags) as string;
const starts = getTagValues("starts", 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 tags = getTagsValues("t", event.tags) as string[];
const total_participants = const total_participants =
getTagValues("total_participants", event.tags) ?? getTagValues("total_participants", event.tags) ??
@ -75,6 +93,7 @@ export default function LiveStreamingSection() {
tags, tags,
title, title,
starts: parseInt(starts), starts: parseInt(starts),
ends: parseInt(ends),
total_participants: total_participants total_participants: total_participants
? parseInt(total_participants) ? parseInt(total_participants)
: undefined, : undefined,

View File

@ -17,9 +17,10 @@ export default function EventPage({
const { data, type } = nip19.decode(key); const { data, type } = nip19.decode(key);
const { events } = useEvents({ const { events } = useEvents({
filter: filter:
type === "nevent" type === "naddr"
? { ? {
ids: [data.id], kinds: [data.kind],
["#d"]: [data.identifier],
limit: 1, limit: 1,
} }
: {}, : {},

View File

@ -5,6 +5,7 @@ export default function ModalLayout(props: {
children: ReactElement; children: ReactElement;
"1": ReactNode; "1": ReactNode;
"30023": ReactNode; "30023": ReactNode;
"30311": ReactNode;
event: ReactNode; event: ReactNode;
params: { params: {
key: string; key: string;
@ -13,11 +14,20 @@ export default function ModalLayout(props: {
const key = props.params.key; const key = props.params.key;
const { data, type } = nip19.decode(key); const { data, type } = nip19.decode(key);
if (type === "naddr") { if (type === "naddr") {
return ( const kind = data.kind;
<div className="z-overlay fixed inset-y-[10px] left-[10px] right-[10px] overflow-hidden overflow-y-auto rounded-lg border bg-background px-4 sm:left-[calc(10px_+_var(--sidebar-closed-width))] xl:left-[calc(10px_+_var(--sidebar-open-width))]"> if (kind === 30023) {
{props[30023]} return (
</div> <div className="z-overlay fixed inset-y-[10px] left-[10px] right-[10px] overflow-hidden overflow-y-auto rounded-lg border bg-background px-4 sm:left-[calc(10px_+_var(--sidebar-closed-width))] xl:left-[calc(10px_+_var(--sidebar-open-width))]">
); {props[30023]}
</div>
);
} else if (kind === 30311) {
return (
<div className="z-overlay fixed inset-y-[10px] left-[10px] right-[10px] overflow-hidden overflow-y-auto rounded-lg border bg-background px-4 sm:left-[calc(10px_+_var(--sidebar-closed-width))] xl:left-[calc(10px_+_var(--sidebar-open-width))]">
{props[30311]}
</div>
);
}
} else if (type === "note") { } else if (type === "note") {
return ( return (
<div className="z-overlay fixed inset-y-[10px] left-[10px] right-[10px] overflow-hidden overflow-y-auto rounded-lg border bg-background px-4 sm:left-[calc(10px_+_var(--sidebar-closed-width))] xl:left-[calc(10px_+_var(--sidebar-open-width))]"> <div className="z-overlay fixed inset-y-[10px] left-[10px] right-[10px] overflow-hidden overflow-y-auto rounded-lg border bg-background px-4 sm:left-[calc(10px_+_var(--sidebar-closed-width))] xl:left-[calc(10px_+_var(--sidebar-open-width))]">

View File

@ -61,7 +61,7 @@ export default function Container({
{children} {children}
<div className="mt-auto"> <div className="mt-auto">
{!!contentTags?.length && ( {!!contentTags?.length && (
<div className="mb-2 mt-1 max-h-[52px] overflow-hidden"> <div className="mb-2.5 mt-1 max-h-[52px] overflow-hidden">
<Tags tags={contentTags} /> <Tags tags={contentTags} />
</div> </div>
)} )}

View File

@ -13,6 +13,7 @@ type VideoCardProps = {
title: string; title: string;
tags: string[]; tags: string[];
starts?: number; starts?: number;
ends?: number;
status: "live" | "planned" | "ended"; status: "live" | "planned" | "ended";
["total_participants"]?: number; ["total_participants"]?: number;
}; };
@ -21,6 +22,7 @@ type VideoCardProps = {
export default function VideoCard({ className, card }: VideoCardProps) { export default function VideoCard({ className, card }: VideoCardProps) {
const startTime = card?.starts ? new Date(card.starts * 1000) : null; const startTime = card?.starts ? new Date(card.starts * 1000) : null;
const endTime = card?.ends ? new Date(card.ends * 1000) : null;
return ( return (
<div <div
className={cn( className={cn(
@ -52,10 +54,17 @@ export default function VideoCard({ className, card }: VideoCardProps) {
<h3 className="line-clamp-2 font-medium leading-none">{card.title}</h3> <h3 className="line-clamp-2 font-medium leading-none">{card.title}</h3>
<div className="flex items-center gap-x-3"> <div className="flex items-center gap-x-3">
<div className="flex flex-col items-start gap-y-1"> <div className="flex flex-col items-start gap-y-1">
{startTime && ( {!!startTime && (
<div className="center gap-x-1 text-xs text-muted-foreground"> <div className="center gap-x-1 text-xs text-muted-foreground">
<RxClock className="h-4 w-4 text-primary" /> <RxClock className="h-4 w-4 text-primary" />
<span>{formatDate(new Date(startTime), "h:m a")}</span> <span>{formatDate(new Date(startTime), "h:m a")}</span>
{!!endTime && (
<>
{" "}
<span>-</span>{" "}
<span>{formatDate(new Date(endTime), "h:m a")}</span>
</>
)}
</div> </div>
)} )}
{!!card["total_participants"] && ( {!!card["total_participants"] && (