mirror of
https://github.com/t4t5/nostr-react.git
synced 2025-05-05 19:40:14 +02:00
Add onDone + enabled params to useProfile
This commit is contained in:
parent
902627c6a9
commit
9c7f628d87
@ -58,14 +58,20 @@ function useProfileQueue({ pubkey }: { pubkey: string }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useProfile({ pubkey }: { pubkey: string }) {
|
export function useProfile({
|
||||||
|
pubkey,
|
||||||
|
enabled: _enabled = true,
|
||||||
|
}: {
|
||||||
|
pubkey: string
|
||||||
|
enabled?: boolean
|
||||||
|
}) {
|
||||||
const [, setRequestedPubkeys] = useAtom(requestedPubkeysAtom)
|
const [, setRequestedPubkeys] = useAtom(requestedPubkeysAtom)
|
||||||
const { pubkeysToFetch } = useProfileQueue({ pubkey })
|
const { pubkeysToFetch } = useProfileQueue({ pubkey })
|
||||||
const enabled = !!pubkeysToFetch.length
|
const enabled = _enabled && !!pubkeysToFetch.length
|
||||||
|
|
||||||
const [fetchedProfiles, setFetchedProfiles] = useAtom(fetchedProfilesAtom)
|
const [fetchedProfiles, setFetchedProfiles] = useAtom(fetchedProfilesAtom)
|
||||||
|
|
||||||
const { onEvent, onSubscribe, isLoading } = useNostrEvents({
|
const { onEvent, onSubscribe, isLoading, onDone } = useNostrEvents({
|
||||||
filter: {
|
filter: {
|
||||||
kinds: [0],
|
kinds: [0],
|
||||||
authors: pubkeysToFetch,
|
authors: pubkeysToFetch,
|
||||||
@ -104,6 +110,7 @@ export function useProfile({ pubkey }: { pubkey: string }) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
isLoading,
|
isLoading,
|
||||||
|
onDone,
|
||||||
data: metadata
|
data: metadata
|
||||||
? {
|
? {
|
||||||
...metadata,
|
...metadata,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user