diff --git a/src/contexts/NDKContext.tsx b/src/contexts/NDKContext.tsx index dd5e605..b89902c 100644 --- a/src/contexts/NDKContext.tsx +++ b/src/contexts/NDKContext.tsx @@ -6,6 +6,7 @@ import NDK, { NDKList, NDKRelaySet, NDKSubscriptionCacheUsage, + NDKSubscriptionOptions, NDKUser, zapInvoiceFromEvent } from '@nostr-dev-kit/ndk' @@ -48,7 +49,10 @@ export interface NDKContextType { hexKey: string, userRelaysType: UserRelaysType ) => Promise - findMetadata: (pubkey: string) => Promise + findMetadata: ( + pubkey: string, + opts?: NDKSubscriptionOptions + ) => Promise getTotalZapAmount: ( user: string, eTag: string, @@ -111,7 +115,12 @@ export const NDKContextProvider = ({ children }: { children: ReactNode }) => { } const ndk = useMemo(() => { - localStorage.removeItem('debug') + if (import.meta.env.MODE === 'development') { + localStorage.setItem('debug', '*') + } else { + localStorage.removeItem('debug') + } + const dexieAdapter = new NDKCacheAdapterDexie({ dbName: 'degmod-db' }) dexieAdapter.locking = true const ndk = new NDK({ @@ -309,13 +318,16 @@ export const NDKContextProvider = ({ children }: { children: ReactNode }) => { * @param hexKey - The pubkey to search for metadata. * @returns A promise that resolves to the metadata event. */ - const findMetadata = async (pubkey: string): Promise => { + const findMetadata = async ( + pubkey: string, + opts?: NDKSubscriptionOptions + ): Promise => { const npub = hexToNpub(pubkey) const user = new NDKUser({ npub }) user.ndk = ndk - const userProfile = await user.fetchProfile() + const userProfile = await user.fetchProfile(opts) return userProfile }