fix: resolve user search returning no results
This commit is contained in:
@@ -43,7 +43,7 @@ export function useSearchProfiles(search: string, limit: number) {
|
|||||||
existingPubkeys.add(profile.pubkey)
|
existingPubkeys.add(profile.pubkey)
|
||||||
profiles.push(profile)
|
profiles.push(profile)
|
||||||
})
|
})
|
||||||
setProfiles(profiles)
|
setProfiles([...profiles])
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err as Error)
|
setError(err as Error)
|
||||||
|
|||||||
@@ -730,7 +730,8 @@ class ClientService extends EventTarget {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const profileEvents = events.sort((a, b) => b.created_at - a.created_at)
|
const profileEvents = events.sort((a, b) => b.created_at - a.created_at)
|
||||||
await Promise.all(profileEvents.map((profile) => this.addUsernameToIndex(profile)))
|
await Promise.allSettled(profileEvents.map((profile) => this.addUsernameToIndex(profile)))
|
||||||
|
profileEvents.forEach((profile) => this.updateProfileEventCache(profile))
|
||||||
return profileEvents.map((profileEvent) => getProfileFromEvent(profileEvent))
|
return profileEvents.map((profileEvent) => getProfileFromEvent(profileEvent))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -927,6 +928,11 @@ class ClientService extends EventTarget {
|
|||||||
indexedDb.putReplaceableEvent(event)
|
indexedDb.putReplaceableEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateProfileEventCache(event: NEvent) {
|
||||||
|
this.fetchProfileEventFromBigRelaysDataloader.clear(event.pubkey)
|
||||||
|
this.fetchProfileEventFromBigRelaysDataloader.prime(event.pubkey, Promise.resolve(event))
|
||||||
|
}
|
||||||
|
|
||||||
async searchNpubsFromCache(query: string, limit: number = 100) {
|
async searchNpubsFromCache(query: string, limit: number = 100) {
|
||||||
const result = await this.userIndex.searchAsync(query, { limit })
|
const result = await this.userIndex.searchAsync(query, { limit })
|
||||||
return result.map((pubkey) => pubkeyToNpub(pubkey as string)).filter(Boolean) as string[]
|
return result.map((pubkey) => pubkeyToNpub(pubkey as string)).filter(Boolean) as string[]
|
||||||
|
|||||||
Reference in New Issue
Block a user