diff --git a/src/storages/hydrate.ts b/src/storages/hydrate.ts index a656d590..36df74f6 100644 --- a/src/storages/hydrate.ts +++ b/src/storages/hydrate.ts @@ -34,6 +34,10 @@ async function hydrateEvents(opts: HydrateOpts): Promise { cache.push(event); } + for (const event of await gatherQuotes({ events: cache, store, signal })) { + cache.push(event); + } + for (const event of await gatherProfiles({ events: cache, store, signal })) { cache.push(event); } @@ -198,13 +202,6 @@ function gatherRelatedEvents({ events, store, signal }: HydrateOpts): Promise(); for (const event of events) { - // Quoted events - if (event.kind === 1) { - const id = findQuoteTag(event.tags)?.[1] || findQuoteInContent(event.content); - if (id) { - ids.add(id); - } - } // Reposted events if (event.kind === 6) { const id = event.tags.find(([name]) => name === 'e')?.[1]; @@ -242,6 +239,25 @@ function gatherRelatedEvents({ events, store, signal }: HydrateOpts): Promise { + const ids = new Set(); + + for (const event of events) { + if (event.kind === 1) { + const id = findQuoteTag(event.tags)?.[1] || findQuoteInContent(event.content); + if (id) { + ids.add(id); + } + } + } + + return store.query( + [{ ids: [...ids], limit: ids.size }], + { signal }, + ); +} + /** Collect profiles from the events. */ async function gatherProfiles({ events, store, signal }: HydrateOpts): Promise { const pubkeys = new Set();