mirror of
https://github.com/dergigi/boris.git
synced 2025-12-17 22:54:30 +01:00
fix: re-check eventStore after fetchProfiles to resolve all profiles
- After fetchProfiles completes, re-check eventStore for all profiles - This ensures profiles are resolved even if fetchProfiles returns partial results - Fixes issue where only 5 out of 19 profiles were being resolved
This commit is contained in:
@@ -83,19 +83,20 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
|||||||
if (pubkeysToFetch.length > 0 && relayPool && eventStore) {
|
if (pubkeysToFetch.length > 0 && relayPool && eventStore) {
|
||||||
console.log('[npub-resolve] Fetching', pubkeysToFetch.length, 'missing profiles')
|
console.log('[npub-resolve] Fetching', pubkeysToFetch.length, 'missing profiles')
|
||||||
fetchProfiles(relayPool, eventStore as unknown as IEventStore, pubkeysToFetch)
|
fetchProfiles(relayPool, eventStore as unknown as IEventStore, pubkeysToFetch)
|
||||||
.then(profiles => {
|
.then(() => {
|
||||||
// Rebuild labels map with fetched profiles
|
// Re-check eventStore for all profiles (including ones we just fetched)
|
||||||
|
// This ensures we get profiles even if fetchProfiles didn't return them in the array
|
||||||
const updatedLabels = new Map(labels)
|
const updatedLabels = new Map(labels)
|
||||||
profileData.forEach(({ encoded, pubkey }) => {
|
profileData.forEach(({ encoded, pubkey }) => {
|
||||||
if (!updatedLabels.has(encoded)) {
|
if (!updatedLabels.has(encoded) && eventStore) {
|
||||||
const profileEvent = profiles.find(p => p.pubkey === pubkey)
|
const profileEvent = eventStore.getEvent(pubkey + ':0')
|
||||||
if (profileEvent) {
|
if (profileEvent) {
|
||||||
try {
|
try {
|
||||||
const profileData = JSON.parse(profileEvent.content || '{}') as { name?: string; display_name?: string; nip05?: string }
|
const profileData = JSON.parse(profileEvent.content || '{}') as { name?: string; display_name?: string; nip05?: string }
|
||||||
const displayName = profileData.display_name || profileData.name || profileData.nip05
|
const displayName = profileData.display_name || profileData.name || profileData.nip05
|
||||||
if (displayName) {
|
if (displayName) {
|
||||||
updatedLabels.set(encoded, `@${displayName}`)
|
updatedLabels.set(encoded, `@${displayName}`)
|
||||||
console.log('[npub-resolve] Fetched profile:', encoded, '->', displayName)
|
console.log('[npub-resolve] Resolved profile:', encoded, '->', displayName)
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// ignore parse errors
|
// ignore parse errors
|
||||||
@@ -103,6 +104,7 @@ export function useProfileLabels(content: string, relayPool?: RelayPool | null):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
console.log('[npub-resolve] After fetch, resolved:', updatedLabels.size, 'out of', profileData.length)
|
||||||
setProfileLabels(updatedLabels)
|
setProfileLabels(updatedLabels)
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|||||||
Reference in New Issue
Block a user