From 9c7f628d87dc1b6b1a33a751388cd16de5fb8b9f Mon Sep 17 00:00:00 2001 From: Tristan Edwards Date: Sun, 29 Jan 2023 19:52:43 +0000 Subject: [PATCH] Add onDone + enabled params to useProfile --- src/useProfile.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/useProfile.tsx b/src/useProfile.tsx index 79b87ff..0efaf28 100644 --- a/src/useProfile.tsx +++ b/src/useProfile.tsx @@ -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 { pubkeysToFetch } = useProfileQueue({ pubkey }) - const enabled = !!pubkeysToFetch.length + const enabled = _enabled && !!pubkeysToFetch.length const [fetchedProfiles, setFetchedProfiles] = useAtom(fetchedProfilesAtom) - const { onEvent, onSubscribe, isLoading } = useNostrEvents({ + const { onEvent, onSubscribe, isLoading, onDone } = useNostrEvents({ filter: { kinds: [0], authors: pubkeysToFetch, @@ -104,6 +110,7 @@ export function useProfile({ pubkey }: { pubkey: string }) { return { isLoading, + onDone, data: metadata ? { ...metadata,