mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
refactor: remove NIP-50 search if looking for accounts, use same filter
This commit is contained in:
parent
a974f4230d
commit
935cc7c5a5
1 changed files with 3 additions and 6 deletions
|
|
@ -91,21 +91,18 @@ async function searchEvents({ q, type, limit, account_id }: SearchQuery, signal:
|
||||||
filter.authors = [account_id];
|
filter.authors = [account_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
const filter2: NostrFilter = {
|
|
||||||
kinds: [0],
|
|
||||||
limit,
|
|
||||||
};
|
|
||||||
if (type === 'accounts') {
|
if (type === 'accounts') {
|
||||||
const kysely = await Storages.kysely();
|
const kysely = await Storages.kysely();
|
||||||
|
|
||||||
const pubkeys = await getPubkeysBySearch(kysely, { q, limit });
|
const pubkeys = await getPubkeysBySearch(kysely, { q, limit });
|
||||||
|
|
||||||
filter2.authors = pubkeys; // if pubkeys is empty the filter 2 will be discarded
|
filter.authors = pubkeys;
|
||||||
|
filter.search = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = await Storages.search();
|
const store = await Storages.search();
|
||||||
|
|
||||||
return store.query([filter, filter2], { signal })
|
return store.query([filter], { signal })
|
||||||
.then((events) => hydrateEvents({ events, store, signal }));
|
.then((events) => hydrateEvents({ events, store, signal }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue