Wait longer for profile photoes.

This commit is contained in:
mplorentz 2026-08-27 15:18:52 -04:00
parent 14bc273d98
commit cf335649c0

View file

@ -104,6 +104,7 @@ export class Digest {
for (const pk of pubkeys) {
try {
await loadProfile(pk)
await waitForProfile(pk)
} catch {
// pass
}
@ -175,4 +176,18 @@ const getFormatter = () => {
timeStyle: 'short',
timeZone: 'UTC',
})
}
// Poll until the profile lands in the repository or hits a timeout. The load
// promise can resolve before sharedLoad writes the event to the store, so only
// the profile's presence here guarantees its avatar/name.
const waitForProfile = async (pubkey: string, timeoutMs = 5000) => {
const deadline = Date.now() + timeoutMs
while (Date.now() < deadline) {
if (profilesByPubkey.get().get(pubkey)) {
return
}
await new Promise(r => setTimeout(r, 200))
}
}