hydrateEvents: early return is only needed for stats?

This commit is contained in:
Alex Gleason 2024-04-23 21:40:02 -05:00
parent a2c3daade7
commit 1f5ba81e98
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 0 additions and 16 deletions

View File

@ -99,10 +99,6 @@ function gatherReposts({ events, storage, signal }: HydrateOpts): Promise<DittoE
} }
} }
if (!ids.size) {
return Promise.resolve([]);
}
return storage.query( return storage.query(
[{ ids: [...ids], limit: ids.size }], [{ ids: [...ids], limit: ids.size }],
{ signal }, { signal },
@ -122,10 +118,6 @@ function gatherQuotes({ events, storage, signal }: HydrateOpts): Promise<DittoEv
} }
} }
if (!ids.size) {
return Promise.resolve([]);
}
return storage.query( return storage.query(
[{ ids: [...ids], limit: ids.size }], [{ ids: [...ids], limit: ids.size }],
{ signal }, { signal },
@ -136,10 +128,6 @@ function gatherQuotes({ events, storage, signal }: HydrateOpts): Promise<DittoEv
function gatherAuthors({ events, storage, signal }: HydrateOpts): Promise<DittoEvent[]> { function gatherAuthors({ events, storage, signal }: HydrateOpts): Promise<DittoEvent[]> {
const pubkeys = new Set(events.map((event) => event.pubkey)); const pubkeys = new Set(events.map((event) => event.pubkey));
if (!pubkeys.size) {
return Promise.resolve([]);
}
return storage.query( return storage.query(
[{ kinds: [0], authors: [...pubkeys], limit: pubkeys.size }], [{ kinds: [0], authors: [...pubkeys], limit: pubkeys.size }],
{ signal }, { signal },
@ -150,10 +138,6 @@ function gatherAuthors({ events, storage, signal }: HydrateOpts): Promise<DittoE
function gatherUsers({ events, storage, signal }: HydrateOpts): Promise<DittoEvent[]> { function gatherUsers({ events, storage, signal }: HydrateOpts): Promise<DittoEvent[]> {
const pubkeys = new Set(events.map((event) => event.pubkey)); const pubkeys = new Set(events.map((event) => event.pubkey));
if (!pubkeys.size) {
return Promise.resolve([]);
}
return storage.query( return storage.query(
[{ kinds: [30361], authors: [Conf.pubkey], '#d': [...pubkeys], limit: pubkeys.size }], [{ kinds: [30361], authors: [Conf.pubkey], '#d': [...pubkeys], limit: pubkeys.size }],
{ signal }, { signal },