feat: improve search results for profiles
This commit is contained in:
@@ -833,11 +833,17 @@ class ClientService extends EventTarget {
|
||||
this.relayListEventDataLoader.prime(event.pubkey, Promise.resolve(event))
|
||||
}
|
||||
|
||||
async searchNpubs(query: string, limit: number = 100) {
|
||||
async searchNpubsFromCache(query: string, limit: number = 100) {
|
||||
const result = await this.userIndex.searchAsync(query, { limit })
|
||||
return result.map((pubkey) => pubkeyToNpub(pubkey as string)).filter(Boolean) as string[]
|
||||
}
|
||||
|
||||
async searchProfilesFromCache(query: string, limit: number = 100) {
|
||||
const npubs = await this.searchNpubsFromCache(query, limit)
|
||||
const profiles = await Promise.all(npubs.map((npub) => this.fetchProfile(npub)))
|
||||
return profiles.filter((profile) => !!profile) as TProfile[]
|
||||
}
|
||||
|
||||
async initUserIndexFromFollowings(pubkey: string, signal: AbortSignal) {
|
||||
const followings = await this.fetchFollowings(pubkey, true)
|
||||
for (let i = 0; i * 20 < followings.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user