From 05a7a773fef013c27ead6cdd39f1cf8a3ad4a9c4 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 19 Aug 2023 12:37:42 -0500 Subject: [PATCH] getFilters: return immediately if filters are empty --- src/client.ts | 1 + src/db/events.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/client.ts b/src/client.ts index e336116..0c55d64 100644 --- a/src/client.ts +++ b/src/client.ts @@ -29,6 +29,7 @@ function getPool(): Pool { /** Get events from a NIP-01 filter. */ function getFilters(filters: Filter[], opts: GetFiltersOpts = {}): Promise[]> { + if (!filters.length) return Promise.resolve([]); return new Promise((resolve) => { let tid: number; const results: Event[] = []; diff --git a/src/db/events.ts b/src/db/events.ts index 7910a40..bbe0d4b 100644 --- a/src/db/events.ts +++ b/src/db/events.ts @@ -108,6 +108,7 @@ async function getFilters( filters: DittoFilter[], opts: GetFiltersOpts = {}, ): Promise[]> { + if (!filters.length) return Promise.resolve([]); let query = filters.map(getFilterQuery).reduce((acc, curr) => acc.union(curr)); if (typeof opts.limit === 'number') {