Wait longer for profile photoes.
This commit is contained in:
parent
14bc273d98
commit
cf335649c0
1 changed files with 15 additions and 0 deletions
|
|
@ -104,6 +104,7 @@ export class Digest {
|
||||||
for (const pk of pubkeys) {
|
for (const pk of pubkeys) {
|
||||||
try {
|
try {
|
||||||
await loadProfile(pk)
|
await loadProfile(pk)
|
||||||
|
await waitForProfile(pk)
|
||||||
} catch {
|
} catch {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
@ -175,4 +176,18 @@ const getFormatter = () => {
|
||||||
timeStyle: 'short',
|
timeStyle: 'short',
|
||||||
timeZone: 'UTC',
|
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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue