cleanup
This commit is contained in:
parent
ffa2fc466b
commit
80be2c0197
@ -5,7 +5,7 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { RiArrowRightLine } from "react-icons/ri";
|
import { RiArrowRightLine } from "react-icons/ri";
|
||||||
import useEvents from "@/lib/hooks/useEvents";
|
import useEvents from "@/lib/hooks/useEvents";
|
||||||
import { nip19 } from "nostr-tools";
|
import { nip19 } from "nostr-tools";
|
||||||
import { type NDKKind } from "@nostr-dev-kit/ndk";
|
import { NDKEvent, type NDKKind } from "@nostr-dev-kit/ndk";
|
||||||
import { uniqBy } from "ramda";
|
import { uniqBy } from "ramda";
|
||||||
|
|
||||||
import CalendarCard, { LoadingCalendarCard } from "../_components/CalendarCard";
|
import CalendarCard, { LoadingCalendarCard } from "../_components/CalendarCard";
|
||||||
@ -45,7 +45,7 @@ function HorizontalCarousel() {
|
|||||||
key={calendar.id}
|
key={calendar.id}
|
||||||
className={cn("snap-start pl-2 sm:pl-5", index === 0 && "pl-5")}
|
className={cn("snap-start pl-2 sm:pl-5", index === 0 && "pl-5")}
|
||||||
>
|
>
|
||||||
<Calendar encodedEvent={calendar.encode()} />
|
<Calendar event={calendar} />
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
@ -67,24 +67,6 @@ function HorizontalCarousel() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Calendar({ encodedEvent }: { encodedEvent: string }) {
|
function Calendar({ event }: { event: NDKEvent }) {
|
||||||
const { type, data } = nip19.decode(encodedEvent);
|
return <CalendarCard calendar={event} />;
|
||||||
if (type !== "naddr") {
|
|
||||||
throw new Error("impoper type");
|
|
||||||
}
|
|
||||||
const { pubkey, identifier, kind } = data;
|
|
||||||
const { events } = useEvents({
|
|
||||||
filter: {
|
|
||||||
authors: [pubkey],
|
|
||||||
["#d"]: [identifier],
|
|
||||||
kinds: [31924 as NDKKind],
|
|
||||||
limit: 1,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const event = events[0];
|
|
||||||
if (!event) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return <CalendarCard calendar={event} key={event.id} />;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user