Merge branch 'descendants-filter' into 'main'

getDescendants: filter out non-replies

See merge request soapbox-pub/ditto!294
This commit is contained in:
Alex Gleason 2024-05-21 19:40:15 +00:00
commit 00cfd0af68
1 changed files with 5 additions and 1 deletions

View File

@ -88,7 +88,11 @@ async function getAncestors(event: NostrEvent, result: NostrEvent[] = []): Promi
async function getDescendants(eventId: string, signal = AbortSignal.timeout(2000)): Promise<NostrEvent[]> { async function getDescendants(eventId: string, signal = AbortSignal.timeout(2000)): Promise<NostrEvent[]> {
const store = await Storages.db(); const store = await Storages.db();
const events = await store.query([{ kinds: [1], '#e': [eventId] }], { limit: 200, signal });
const events = await store
.query([{ kinds: [1], '#e': [eventId] }], { limit: 200, signal })
.then((events) => events.filter(({ tags }) => findReplyTag(tags)?.[1] === eventId));
return hydrateEvents({ events, store, signal }); return hydrateEvents({ events, store, signal });
} }