Fix stale profile data #214
@ -1,18 +1,19 @@
|
||||
import { NDKSubscriptionOptions } from '@nostr-dev-kit/ndk'
|
||||
import { useNDKContext } from 'hooks'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { UserProfile } from 'types'
|
||||
|
||||
export const useProfile = (pubkey?: string) => {
|
||||
export const useProfile = (pubkey?: string, opts?: NDKSubscriptionOptions) => {
|
||||
const { findMetadata } = useNDKContext()
|
||||
const [profile, setProfile] = useState<UserProfile>()
|
||||
|
||||
useEffect(() => {
|
||||
if (pubkey) {
|
||||
findMetadata(pubkey).then((res) => {
|
||||
findMetadata(pubkey, opts).then((res) => {
|
||||
setProfile(res)
|
||||
})
|
||||
}
|
||||
}, [findMetadata, pubkey])
|
||||
}, [findMetadata, pubkey, opts])
|
||||
|
||||
return profile
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user