Fix event hydration with getEvent/getAuthor

This commit is contained in:
Alex Gleason 2025-02-22 21:40:53 -06:00
parent 6f1312b67f
commit 7f059b4dac
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -19,8 +19,8 @@ interface GetEventOpts {
*/ */
async function getEvent(id: string, opts: GetEventOpts): Promise<DittoEvent | undefined> { async function getEvent(id: string, opts: GetEventOpts): Promise<DittoEvent | undefined> {
const filter: NostrFilter = { ids: [id], limit: 1 }; const filter: NostrFilter = { ids: [id], limit: 1 };
const [event] = await opts.relay.query([filter], opts); const events = await opts.relay.query([filter], opts);
hydrateEvents({ ...opts, events: [event] }); const [event] = await hydrateEvents({ ...opts, events });
return event; return event;
} }
@ -29,8 +29,8 @@ async function getEvent(id: string, opts: GetEventOpts): Promise<DittoEvent | un
* @deprecated Use `relay.query` directly. * @deprecated Use `relay.query` directly.
*/ */
async function getAuthor(pubkey: string, opts: GetEventOpts): Promise<NostrEvent | undefined> { async function getAuthor(pubkey: string, opts: GetEventOpts): Promise<NostrEvent | undefined> {
const [event] = await opts.relay.query([{ authors: [pubkey], kinds: [0], limit: 1 }], opts); const events = await opts.relay.query([{ authors: [pubkey], kinds: [0], limit: 1 }], opts);
hydrateEvents({ ...opts, events: [event] }); const [event] = await hydrateEvents({ ...opts, events });
return event; return event;
} }