diff --git a/src/controllers/api/statuses.ts b/src/controllers/api/statuses.ts index 817f988..01e947a 100644 --- a/src/controllers/api/statuses.ts +++ b/src/controllers/api/statuses.ts @@ -220,6 +220,12 @@ const contextController: AppController = async (c) => { getDescendants(store, event.id).then(renderStatuses), ]); + await hydrateEvents({ + events: [...ancestors, ...descendants], + signal: c.req.raw.signal, + store, + }); + return c.json({ ancestors, descendants }); } diff --git a/src/queries.ts b/src/queries.ts index bf4fce2..a6fb832 100644 --- a/src/queries.ts +++ b/src/queries.ts @@ -74,7 +74,7 @@ async function getAncestors(store: NStore, event: NostrEvent, result: NostrEvent const inReplyTo = replyTag ? replyTag[1] : undefined; if (inReplyTo) { - const parentEvent = await getEvent(inReplyTo, { kind: 1 }); + const [parentEvent] = await store.query([{ ids: [inReplyTo], limit: 1 }]); if (parentEvent) { result.push(parentEvent); @@ -91,11 +91,9 @@ async function getDescendants( eventId: string, signal = AbortSignal.timeout(2000), ): Promise { - const events = await store + return await store .query([{ kinds: [1], '#e': [eventId], limit: 200 }], { signal }) .then((events) => events.filter(({ tags }) => findReplyTag(tags)?.[1] === eventId)); - - return hydrateEvents({ events, store, signal }); } /** Returns whether the pubkey is followed by a local user. */