Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetchProfile() doesn't return NDKUserProfile on first load #232

Open
mmalmi opened this issue May 31, 2024 · 0 comments
Open

fetchProfile() doesn't return NDKUserProfile on first load #232

mmalmi opened this issue May 31, 2024 · 0 comments

Comments

@mmalmi
Copy link

mmalmi commented May 31, 2024

On the first load, user.fetchProfile doesn't return NDKUserProfile, but an object which has pubkey, profile and created_at properties. On consecutive loads, it returns the NDKUserProfile correctly.

const user = ndk().getUser({pubkey: pubKeyHex})
console.log("Fetching profile for", pubKeyHex)
let profile = await user.fetchProfile({closeOnEose: false})
console.log("Profile fetched", JSON.stringify(profile), profile)
 console.log("profile image", profile?.image)
if (profile && profile.image) {
  console.log("Setting profile image", profile.image)
  setImage(profile.image)
  handleProfile(pubKeyHex, profile)
}

Output:

Fetching profile for 4523be58d395b1b196a9b8c82b038b6895cb02b683d0c253a955068dba1facd0
Avatar.tsx:41 Profile fetched {
  "pubkey": "4523be58d395b1b196a9b8c82b038b6895cb02b683d0c253a955068dba1facd0",
  "profile": {
    "banner": "https://nostr.build/i/nostr.build_59dc3be449d722379b12c095566cf4aeafae9b437d3afaf356ffc69370e93cc7.jpg",
    "website": "https://twitter.com/marttimalmi",
    "nip05": "[email protected]",
    "image": "https://cdn.nostr.build/i/8274ce86cc4477b80c8cad5ff4dfebe55f1223b3e35dfc10a1e19a67f29a8f8f.jpg",
    "lud16": "[email protected]",
    "about": "iris.to dev. 🇫🇮",
    "name": "Martti Malmi",
    "nip05valid": true
  },
  "createdAt": 1717145373722
}
Avatar.tsx:42 profile image undefined

NDK version:

nostr-dev-kit/ndk 2.8.2
nostr-dev-kit/ndk-cache-dexie 2.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant