From 55bd996970ac0edaf390f960993a8e23ee6b9bec Mon Sep 17 00:00:00 2001 From: codytseng Date: Mon, 3 Mar 2025 11:37:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/PostEditor/SendOnlyToSwitch.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/PostEditor/SendOnlyToSwitch.tsx b/src/components/PostEditor/SendOnlyToSwitch.tsx index 85b6f1c..16d2a5c 100644 --- a/src/components/PostEditor/SendOnlyToSwitch.tsx +++ b/src/components/PostEditor/SendOnlyToSwitch.tsx @@ -7,7 +7,7 @@ import { useFeed } from '@/providers/FeedProvider' import client from '@/services/client.service' import { Info } from 'lucide-react' import { Event } from 'nostr-tools' -import { Dispatch, SetStateAction, useMemo } from 'react' +import { Dispatch, SetStateAction, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' export default function SendOnlyToSwitch({ @@ -21,15 +21,18 @@ export default function SendOnlyToSwitch({ }) { const { t } = useTranslation() const { relayUrls } = useFeed() - const urls = useMemo(() => { - if (!parentEvent) return relayUrls + const [urls, setUrls] = useState([]) + + useEffect(() => { + if (!parentEvent) return const isProtected = isProtectedEvent(parentEvent) const seenOn = client.getSeenEventRelayUrls(parentEvent.id) if (isProtected && seenOn.length) { setSpecifiedRelayUrls(seenOn) - return seenOn + setUrls(seenOn) + } else { + setUrls(relayUrls) } - return relayUrls }, [parentEvent, relayUrls]) if (!urls.length) return null