changing how events are referenced (using bech32 thx Pablo)
This commit is contained in:
parent
bd410c0b49
commit
688b27feb1
@ -51,3 +51,18 @@ export default function BottomNav() {
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
|
||||
const test = {
|
||||
id: "cd6bff4b8ddc18e8d99d4075c229d174b5101f6c3ae3bf178abe9176dd9e50c0",
|
||||
pubkey: "17717ad4d20e2a425cda0a2195624a0a4a73c4f6975f16b1593fc87fa46f2d58",
|
||||
created_at: 1699013775,
|
||||
kind: 1,
|
||||
tags: [
|
||||
[
|
||||
"a",
|
||||
"naddr1qqyxzdmyvyukyerpqyfhwumn8ghj7un9d3shjctzd3jjummjvupzqjm3fx8tusvwrsytszzf6k2jv73stwe208dnuznuw6xduxzqu50dqvzqqqrukvqkqn72",
|
||||
],
|
||||
],
|
||||
content: "This Event looks awesome!",
|
||||
sig: "68f3590eaf2a11a4b23692a029d11bc6cfe8bf15d7dc955553795fbbeb5eeec5786fb4bb9ca559af842582e086aa13f9005f2a8079b753ee95b49fcca33f6297",
|
||||
};
|
||||
|
@ -29,6 +29,7 @@ export default function EventPage({
|
||||
throw new Error("Invalid list");
|
||||
}
|
||||
const { identifier, kind, pubkey } = data;
|
||||
const bech32 = `${kind}:${pubkey}:${identifier}`;
|
||||
const { events } = useEvents({
|
||||
filter: {
|
||||
authors: [pubkey],
|
||||
|
@ -17,11 +17,12 @@ type CalendarInfoProps = {
|
||||
};
|
||||
export default function CalendarInfo({ eventReference }: CalendarInfoProps) {
|
||||
console.log("eventReference", eventReference);
|
||||
const { type, data } = nip19.decode(eventReference);
|
||||
if (type !== "naddr") {
|
||||
throw new Error("Invalid list");
|
||||
}
|
||||
const { pubkey } = data;
|
||||
const [kind, pubkey, identifier] = eventReference.split(":") as [
|
||||
string,
|
||||
string,
|
||||
string,
|
||||
];
|
||||
|
||||
const { ndk } = useNDK();
|
||||
const [event, setEvent] = useState<NDKEvent>();
|
||||
const [isFetching, setIsFetching] = useState(false);
|
||||
|
@ -44,7 +44,7 @@ export default function Header({ event }: { event: NDKEvent }) {
|
||||
const [hasValidPayment, setHasValidPayment] = useState(false);
|
||||
const { pubkey, tags } = event;
|
||||
const { profile } = useProfile(pubkey);
|
||||
const eventReference = event.encode();
|
||||
const eventReference = event.tagId();
|
||||
const title = getTagValues("name", tags) ?? "Untitled";
|
||||
const image =
|
||||
getTagValues("image", tags) ??
|
||||
|
@ -26,7 +26,7 @@ export default function RSVPButton({ event }: RSVPButtonProps) {
|
||||
const modal = useModal();
|
||||
const { currentUser } = useCurrentUser();
|
||||
const { ndk } = useNDK();
|
||||
const eventReference = event.encode();
|
||||
const eventReference = event.tagId();
|
||||
const name = getTagValues("name", event.tags);
|
||||
const tickets = getTagValues("tickets", event.tags);
|
||||
const price = getTagAllValues("price", event.tags);
|
||||
|
@ -31,7 +31,7 @@ export default function EventPage({
|
||||
throw new Error("Invalid list");
|
||||
}
|
||||
const { identifier, kind, pubkey } = data;
|
||||
|
||||
const bech32 = `${kind}:${pubkey}:${identifier}`;
|
||||
const { events } = useEvents({
|
||||
filter: {
|
||||
authors: [pubkey],
|
||||
@ -67,7 +67,7 @@ export default function EventPage({
|
||||
);
|
||||
}
|
||||
const { tags } = event;
|
||||
const eventReference = event.tagId();
|
||||
const eventTagId = event.tagId();
|
||||
|
||||
const location = getTagAllValues("location", tags)[0]
|
||||
? getTagAllValues("location", tags)
|
||||
@ -96,11 +96,8 @@ export default function EventPage({
|
||||
<AttendeesContainer attendees={attendees} />
|
||||
</div>
|
||||
<div className="max-w-2xl grow space-y-4">
|
||||
<AnnouncementsContainer
|
||||
eventReference={eventReference}
|
||||
hosts={hosts}
|
||||
/>
|
||||
<DiscussionContainer eventReference={eventReference} />
|
||||
<AnnouncementsContainer eventReference={eventTagId} hosts={hosts} />
|
||||
<DiscussionContainer eventReference={eventTagId} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -163,20 +163,19 @@ export default function CreateCalendarEventModal({
|
||||
const event = await createEvent(ndk, preEvent);
|
||||
|
||||
if (event) {
|
||||
const encodedEvent = event.encode();
|
||||
const encodedEvent = event.tagId();
|
||||
if (calendar) {
|
||||
const selectedCalendar = Array.from(calendars)
|
||||
.find((option) => option.tagId() === calendar)
|
||||
?.rawEvent();
|
||||
if (selectedCalendar) {
|
||||
console.log("selectedCalendar", selectedCalendar);
|
||||
|
||||
await updateList(ndk, selectedCalendar, [["a", encodedEvent]]);
|
||||
}
|
||||
}
|
||||
toast.success("Event Created!");
|
||||
modal?.hide();
|
||||
router.push(`/event/${encodedEvent}`);
|
||||
router.push(`/event/${event.encode()}`);
|
||||
} else {
|
||||
toast.error("An error occured");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user