2023-10-17 09:06:09 -04:00
|
|
|
"use client";
|
|
|
|
import { useState } from "react";
|
|
|
|
import Image from "next/image";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
import SubscriptionCard from "@/components/SubscriptionCard";
|
|
|
|
import { HiCheckBadge } from "react-icons/hi2";
|
|
|
|
import Tabs from "@/components/Tabs";
|
|
|
|
import useProfile from "@/lib/hooks/useProfile";
|
|
|
|
import { getTwoLetters, truncateText } from "@/lib/utils";
|
|
|
|
import { nip19 } from "nostr-tools";
|
|
|
|
import useEvents from "@/lib/hooks/useEvents";
|
|
|
|
import Spinner from "@/components/spinner";
|
2023-10-17 10:41:32 -04:00
|
|
|
import { getTagValues, getTagsValues } from "@/lib/nostr/utils";
|
|
|
|
import ProfileInfo from "./_components/ProfileInfo";
|
|
|
|
import Feed from "@/containers/Feed";
|
2023-10-17 15:58:04 -04:00
|
|
|
import useCurrentUser from "@/lib/hooks/useCurrentUser";
|
|
|
|
import Header from "./_components/Header";
|
2023-10-17 09:06:09 -04:00
|
|
|
|
|
|
|
export default function ListPage({
|
|
|
|
params: { naddr },
|
|
|
|
}: {
|
|
|
|
params: {
|
|
|
|
naddr: string;
|
|
|
|
};
|
|
|
|
}) {
|
|
|
|
const { type, data } = nip19.decode(naddr);
|
|
|
|
if (type !== "naddr") {
|
|
|
|
throw new Error("Invalid list");
|
|
|
|
}
|
|
|
|
const { identifier, kind, pubkey } = data;
|
|
|
|
const { events } = useEvents({
|
|
|
|
filter: {
|
|
|
|
authors: [pubkey],
|
|
|
|
kinds: [kind],
|
|
|
|
["#d"]: [identifier],
|
|
|
|
limit: 1,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
const event = events[0];
|
|
|
|
|
|
|
|
if (!event) {
|
|
|
|
return (
|
2023-10-17 10:41:32 -04:00
|
|
|
<div className="center pt-20 text-primary">
|
2023-10-17 09:06:09 -04:00
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2023-10-17 10:41:32 -04:00
|
|
|
const noteIds = getTagsValues("e", event.tags).filter(Boolean);
|
2023-10-17 11:08:27 -04:00
|
|
|
console.log("notes", event.tags);
|
2023-10-17 09:06:09 -04:00
|
|
|
|
|
|
|
return (
|
2023-10-17 10:41:32 -04:00
|
|
|
<div className="relative mx-auto max-w-5xl space-y-4 p-2 sm:p-4">
|
2023-10-17 15:58:04 -04:00
|
|
|
<Header naddr={naddr} />
|
2023-10-17 10:41:32 -04:00
|
|
|
<div className="relative overflow-hidden rounded-[1rem] border bg-muted p-[0.5rem] @container">
|
2023-10-17 13:16:10 -04:00
|
|
|
<div className="space-y-3 overflow-hidden rounded-[0.5rem] p-0">
|
2023-10-17 10:41:32 -04:00
|
|
|
<Feed
|
|
|
|
filter={{
|
|
|
|
ids: noteIds,
|
|
|
|
}}
|
2023-10-17 09:06:09 -04:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|