Fix stale profile data #214

Merged
enes merged 6 commits from issues/208-profile-box-cache into staging 2025-02-03 16:43:49 +00:00
Showing only changes of commit a5c1f1db74 - Show all commits

View File

@ -1,18 +1,19 @@
import { NDKSubscriptionOptions } from '@nostr-dev-kit/ndk'
import { useNDKContext } from 'hooks' import { useNDKContext } from 'hooks'
import { useState, useEffect } from 'react' import { useState, useEffect } from 'react'
import { UserProfile } from 'types' import { UserProfile } from 'types'
export const useProfile = (pubkey?: string) => { export const useProfile = (pubkey?: string, opts?: NDKSubscriptionOptions) => {
const { findMetadata } = useNDKContext() const { findMetadata } = useNDKContext()
const [profile, setProfile] = useState<UserProfile>() const [profile, setProfile] = useState<UserProfile>()
useEffect(() => { useEffect(() => {
if (pubkey) { if (pubkey) {
findMetadata(pubkey).then((res) => { findMetadata(pubkey, opts).then((res) => {
setProfile(res) setProfile(res)
}) })
} }
}, [findMetadata, pubkey]) }, [findMetadata, pubkey, opts])
return profile return profile
} }