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>
|
</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");
|
throw new Error("Invalid list");
|
||||||
}
|
}
|
||||||
const { identifier, kind, pubkey } = data;
|
const { identifier, kind, pubkey } = data;
|
||||||
|
const bech32 = `${kind}:${pubkey}:${identifier}`;
|
||||||
const { events } = useEvents({
|
const { events } = useEvents({
|
||||||
filter: {
|
filter: {
|
||||||
authors: [pubkey],
|
authors: [pubkey],
|
||||||
|
@ -17,11 +17,12 @@ type CalendarInfoProps = {
|
|||||||
};
|
};
|
||||||
export default function CalendarInfo({ eventReference }: CalendarInfoProps) {
|
export default function CalendarInfo({ eventReference }: CalendarInfoProps) {
|
||||||
console.log("eventReference", eventReference);
|
console.log("eventReference", eventReference);
|
||||||
const { type, data } = nip19.decode(eventReference);
|
const [kind, pubkey, identifier] = eventReference.split(":") as [
|
||||||
if (type !== "naddr") {
|
string,
|
||||||
throw new Error("Invalid list");
|
string,
|
||||||
}
|
string,
|
||||||
const { pubkey } = data;
|
];
|
||||||
|
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const [event, setEvent] = useState<NDKEvent>();
|
const [event, setEvent] = useState<NDKEvent>();
|
||||||
const [isFetching, setIsFetching] = useState(false);
|
const [isFetching, setIsFetching] = useState(false);
|
||||||
|
@ -44,7 +44,7 @@ export default function Header({ event }: { event: NDKEvent }) {
|
|||||||
const [hasValidPayment, setHasValidPayment] = useState(false);
|
const [hasValidPayment, setHasValidPayment] = useState(false);
|
||||||
const { pubkey, tags } = event;
|
const { pubkey, tags } = event;
|
||||||
const { profile } = useProfile(pubkey);
|
const { profile } = useProfile(pubkey);
|
||||||
const eventReference = event.encode();
|
const eventReference = event.tagId();
|
||||||
const title = getTagValues("name", tags) ?? "Untitled";
|
const title = getTagValues("name", tags) ?? "Untitled";
|
||||||
const image =
|
const image =
|
||||||
getTagValues("image", tags) ??
|
getTagValues("image", tags) ??
|
||||||
|
@ -26,7 +26,7 @@ export default function RSVPButton({ event }: RSVPButtonProps) {
|
|||||||
const modal = useModal();
|
const modal = useModal();
|
||||||
const { currentUser } = useCurrentUser();
|
const { currentUser } = useCurrentUser();
|
||||||
const { ndk } = useNDK();
|
const { ndk } = useNDK();
|
||||||
const eventReference = event.encode();
|
const eventReference = event.tagId();
|
||||||
const name = getTagValues("name", event.tags);
|
const name = getTagValues("name", event.tags);
|
||||||
const tickets = getTagValues("tickets", event.tags);
|
const tickets = getTagValues("tickets", event.tags);
|
||||||
const price = getTagAllValues("price", event.tags);
|
const price = getTagAllValues("price", event.tags);
|
||||||
|
@ -31,7 +31,7 @@ export default function EventPage({
|
|||||||
throw new Error("Invalid list");
|
throw new Error("Invalid list");
|
||||||
}
|
}
|
||||||
const { identifier, kind, pubkey } = data;
|
const { identifier, kind, pubkey } = data;
|
||||||
|
const bech32 = `${kind}:${pubkey}:${identifier}`;
|
||||||
const { events } = useEvents({
|
const { events } = useEvents({
|
||||||
filter: {
|
filter: {
|
||||||
authors: [pubkey],
|
authors: [pubkey],
|
||||||
@ -67,7 +67,7 @@ export default function EventPage({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const { tags } = event;
|
const { tags } = event;
|
||||||
const eventReference = event.tagId();
|
const eventTagId = event.tagId();
|
||||||
|
|
||||||
const location = getTagAllValues("location", tags)[0]
|
const location = getTagAllValues("location", tags)[0]
|
||||||
? getTagAllValues("location", tags)
|
? getTagAllValues("location", tags)
|
||||||
@ -96,11 +96,8 @@ export default function EventPage({
|
|||||||
<AttendeesContainer attendees={attendees} />
|
<AttendeesContainer attendees={attendees} />
|
||||||
</div>
|
</div>
|
||||||
<div className="max-w-2xl grow space-y-4">
|
<div className="max-w-2xl grow space-y-4">
|
||||||
<AnnouncementsContainer
|
<AnnouncementsContainer eventReference={eventTagId} hosts={hosts} />
|
||||||
eventReference={eventReference}
|
<DiscussionContainer eventReference={eventTagId} />
|
||||||
hosts={hosts}
|
|
||||||
/>
|
|
||||||
<DiscussionContainer eventReference={eventReference} />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -163,20 +163,19 @@ export default function CreateCalendarEventModal({
|
|||||||
const event = await createEvent(ndk, preEvent);
|
const event = await createEvent(ndk, preEvent);
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
const encodedEvent = event.encode();
|
const encodedEvent = event.tagId();
|
||||||
if (calendar) {
|
if (calendar) {
|
||||||
const selectedCalendar = Array.from(calendars)
|
const selectedCalendar = Array.from(calendars)
|
||||||
.find((option) => option.tagId() === calendar)
|
.find((option) => option.tagId() === calendar)
|
||||||
?.rawEvent();
|
?.rawEvent();
|
||||||
if (selectedCalendar) {
|
if (selectedCalendar) {
|
||||||
console.log("selectedCalendar", selectedCalendar);
|
console.log("selectedCalendar", selectedCalendar);
|
||||||
|
|
||||||
await updateList(ndk, selectedCalendar, [["a", encodedEvent]]);
|
await updateList(ndk, selectedCalendar, [["a", encodedEvent]]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toast.success("Event Created!");
|
toast.success("Event Created!");
|
||||||
modal?.hide();
|
modal?.hide();
|
||||||
router.push(`/event/${encodedEvent}`);
|
router.push(`/event/${event.encode()}`);
|
||||||
} else {
|
} else {
|
||||||
toast.error("An error occured");
|
toast.error("An error occured");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user