mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-17 04:14:25 +01:00
refactor: make getPubkeysBySearch() function return Set<string>
This commit is contained in:
@@ -137,7 +137,7 @@ const accountSearchController: AppController = async (c) => {
|
||||
}
|
||||
|
||||
const followedPubkeys: Set<string> = viewerPubkey ? await getFollowedPubkeys(viewerPubkey) : new Set();
|
||||
const pubkeys = (await getPubkeysBySearch(kysely, { q: query, limit, followedPubkeys })).slice(0, limit);
|
||||
const pubkeys = Array.from(await getPubkeysBySearch(kysely, { q: query, limit, followedPubkeys }));
|
||||
|
||||
let events = event ? [event] : await store.query([{ kinds: [0], authors: pubkeys, limit }], {
|
||||
signal,
|
||||
|
||||
@@ -92,15 +92,15 @@ async function searchEvents(
|
||||
filter.authors = [account_id];
|
||||
}
|
||||
|
||||
const pubkeys: string[] = [];
|
||||
let pubkeys: Set<string> = new Set();
|
||||
if (type === 'accounts') {
|
||||
const kysely = await Storages.kysely();
|
||||
|
||||
const followedPubkeys: Set<string> = viewerPubkey ? await getFollowedPubkeys(viewerPubkey) : new Set();
|
||||
pubkeys.push(...(await getPubkeysBySearch(kysely, { q, limit, followedPubkeys })));
|
||||
pubkeys = pubkeys.union(await getPubkeysBySearch(kysely, { q, limit, followedPubkeys }));
|
||||
|
||||
if (!filter?.authors) {
|
||||
filter.authors = pubkeys;
|
||||
filter.authors = Array.from(pubkeys);
|
||||
} else {
|
||||
filter.authors.push(...pubkeys);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ async function searchEvents(
|
||||
|
||||
if (type !== 'accounts') return events;
|
||||
|
||||
events = pubkeys
|
||||
events = Array.from(pubkeys)
|
||||
.map((pubkey) => events.find((event) => event.pubkey === pubkey))
|
||||
.filter((event) => !!event);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user