This commit is contained in:
zmeyer44 2023-11-03 09:14:20 -04:00
parent 688b27feb1
commit 76a27611c5
2 changed files with 38 additions and 2 deletions

View File

@ -42,7 +42,25 @@ export default function CalendarCard({ calendar }: CalendarCardProps) {
const calendarEvents = getTagsValues("a", tags);
const calendarEventIdentifiers = calendarEvents
.filter(Boolean)
.map((e) => nip19.decode(e))
.map((e) => {
if (nip19.BECH32_REGEX.test(e) && e.includes(":")) {
const [kind, pubkey, identifier] = e.split(":") as [
string,
string,
string,
];
return {
type: "naddr",
data: {
kind,
pubkey,
identifier,
},
};
} else {
return nip19.decode(e);
}
})
.filter(({ type }) => type === "naddr")
.map((e) => e.data as nip19.AddressPointer);
const { events } = useEvents({

View File

@ -25,7 +25,25 @@ export default function EventsFromCalendar({
const calendarEventIdentifiers = calendarEvents
.filter(Boolean)
.map((e) => nip19.decode(e))
.map((e) => {
if (nip19.BECH32_REGEX.test(e) && e.includes(":")) {
const [kind, pubkey, identifier] = e.split(":") as [
string,
string,
string,
];
return {
type: "naddr",
data: {
kind,
pubkey,
identifier,
},
};
} else {
return nip19.decode(e);
}
})
.filter(({ type }) => type === "naddr")
.map((e) => e.data as nip19.AddressPointer);
const { events, isLoading } = useEvents({