Browse Source

fix: reattempt to get user profiles

as they often are not recieved the first time
master
DanConwayDev 2 years ago
parent
commit
290650a435
No known key found for this signature in database
GPG Key ID: 68E15486D73F75E1
  1. 17
      src/lib/stores/users.ts

17
src/lib/stores/users.ts

@ -20,6 +20,7 @@ export const ensureUser = (hexpubkey: string): Writable<UserObject> => {
users[hexpubkey] = writable(base) users[hexpubkey] = writable(base)
getUserRelays(hexpubkey) getUserRelays(hexpubkey)
const getProfile = () => {
u.fetchProfile({ u.fetchProfile({
closeOnEose: true, closeOnEose: true,
groupable: true, groupable: true,
@ -41,6 +42,22 @@ export const ensureUser = (hexpubkey: string): Writable<UserObject> => {
} }
) )
} }
let attempts = 1
const tryAgainin3s = () => {
setTimeout(
() => {
if (!get(users[hexpubkey]).profile) {
getProfile()
attempts++
if (attempts < 5) tryAgainin3s()
}
},
(attempts ^ 2) * 1000
)
}
getProfile()
tryAgainin3s()
}
return users[hexpubkey] return users[hexpubkey]
} }

Loading…
Cancel
Save