From 72d9b2ac4cee6d31c36217a210b942c6a5073c6a Mon Sep 17 00:00:00 2001 From: en Date: Thu, 27 Feb 2025 20:08:53 +0100 Subject: [PATCH] fix(ln): skip cache for profile metadata --- src/components/Internal/Zap.tsx | 5 ++++- src/components/ProfileSection.tsx | 4 ++-- src/components/Zap.tsx | 17 +++++++++++++---- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/components/Internal/Zap.tsx b/src/components/Internal/Zap.tsx index 474d908..19a7800 100644 --- a/src/components/Internal/Zap.tsx +++ b/src/components/Internal/Zap.tsx @@ -1,3 +1,4 @@ +import { NDKSubscriptionCacheUsage } from '@nostr-dev-kit/ndk' import { Dots } from 'components/Spinner' import { ZapSplit } from 'components/Zap' import { @@ -28,7 +29,9 @@ export const Zap = ({ addressable }: ZapProps) => { useBodyScrollDisable(isOpen) useDidMount(() => { - findMetadata(addressable.author) + findMetadata(addressable.author, { + cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY + }) .then((res) => { setIsAvailable(typeof res?.lud16 !== 'undefined' && res.lud16 !== '') }) diff --git a/src/components/ProfileSection.tsx b/src/components/ProfileSection.tsx index 2d5dd41..39d8949 100644 --- a/src/components/ProfileSection.tsx +++ b/src/components/ProfileSection.tsx @@ -44,7 +44,7 @@ type Props = { export const ProfileSection = ({ pubkey }: Props) => { const { ndk } = useNDKContext() const profile = useProfile(pubkey, { - cacheUsage: NDKSubscriptionCacheUsage.PARALLEL + cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY }) const displayName = profile?.displayName || profile?.name || '[name not set up]' @@ -151,7 +151,7 @@ type ProfileProps = { export const Profile = ({ pubkey }: ProfileProps) => { const profile = useProfile(pubkey, { - cacheUsage: NDKSubscriptionCacheUsage.PARALLEL + cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY }) const displayName = diff --git a/src/components/Zap.tsx b/src/components/Zap.tsx index f95863b..da348b5 100644 --- a/src/components/Zap.tsx +++ b/src/components/Zap.tsx @@ -1,4 +1,7 @@ -import { getRelayListForUser } from '@nostr-dev-kit/ndk' +import { + getRelayListForUser, + NDKSubscriptionCacheUsage +} from '@nostr-dev-kit/ndk' import { QRCodeSVG } from 'qrcode.react' import React, { Dispatch, @@ -318,7 +321,9 @@ export const ZapPopUp = ({ setLoadingSpinnerDesc('Finding receiver metadata') - const receiverMetadata = await findMetadata(receiver) + const receiverMetadata = await findMetadata(receiver, { + cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY + }) if (!receiverMetadata?.lud16) { setIsLoading(false) @@ -552,12 +557,16 @@ export const ZapSplit = ({ const [invoices, setInvoices] = useState>() useDidMount(async () => { - findMetadata(pubkey).then((res) => { + findMetadata(pubkey, { + cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY + }).then((res) => { setAuthor(res) }) const adminNpubs = import.meta.env.VITE_ADMIN_NPUBS.split(',') - findMetadata(adminNpubs[0]).then((res) => { + findMetadata(adminNpubs[0], { + cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY + }).then((res) => { setAdmin(res) }) })