Fix thread hydration
This commit is contained in:
parent
c5c4f47bc2
commit
f7a9bf9ffd
|
@ -220,6 +220,12 @@ const contextController: AppController = async (c) => {
|
||||||
getDescendants(store, event.id).then(renderStatuses),
|
getDescendants(store, event.id).then(renderStatuses),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
await hydrateEvents({
|
||||||
|
events: [...ancestors, ...descendants],
|
||||||
|
signal: c.req.raw.signal,
|
||||||
|
store,
|
||||||
|
});
|
||||||
|
|
||||||
return c.json({ ancestors, descendants });
|
return c.json({ ancestors, descendants });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ async function getAncestors(store: NStore, event: NostrEvent, result: NostrEvent
|
||||||
const inReplyTo = replyTag ? replyTag[1] : undefined;
|
const inReplyTo = replyTag ? replyTag[1] : undefined;
|
||||||
|
|
||||||
if (inReplyTo) {
|
if (inReplyTo) {
|
||||||
const parentEvent = await getEvent(inReplyTo, { kind: 1 });
|
const [parentEvent] = await store.query([{ ids: [inReplyTo], limit: 1 }]);
|
||||||
|
|
||||||
if (parentEvent) {
|
if (parentEvent) {
|
||||||
result.push(parentEvent);
|
result.push(parentEvent);
|
||||||
|
@ -91,11 +91,9 @@ async function getDescendants(
|
||||||
eventId: string,
|
eventId: string,
|
||||||
signal = AbortSignal.timeout(2000),
|
signal = AbortSignal.timeout(2000),
|
||||||
): Promise<NostrEvent[]> {
|
): Promise<NostrEvent[]> {
|
||||||
const events = await store
|
return await store
|
||||||
.query([{ kinds: [1], '#e': [eventId], limit: 200 }], { signal })
|
.query([{ kinds: [1], '#e': [eventId], limit: 200 }], { signal })
|
||||||
.then((events) => events.filter(({ tags }) => findReplyTag(tags)?.[1] === eventId));
|
.then((events) => events.filter(({ tags }) => findReplyTag(tags)?.[1] === eventId));
|
||||||
|
|
||||||
return hydrateEvents({ events, store, signal });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether the pubkey is followed by a local user. */
|
/** Returns whether the pubkey is followed by a local user. */
|
||||||
|
|
Loading…
Reference in New Issue