fix: 🐛

This commit is contained in:
codytseng
2025-03-03 11:37:35 +08:00
parent 08d055035b
commit 55bd996970

View File

@@ -7,7 +7,7 @@ import { useFeed } from '@/providers/FeedProvider'
import client from '@/services/client.service' import client from '@/services/client.service'
import { Info } from 'lucide-react' import { Info } from 'lucide-react'
import { Event } from 'nostr-tools' import { Event } from 'nostr-tools'
import { Dispatch, SetStateAction, useMemo } from 'react' import { Dispatch, SetStateAction, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
export default function SendOnlyToSwitch({ export default function SendOnlyToSwitch({
@@ -21,15 +21,18 @@ export default function SendOnlyToSwitch({
}) { }) {
const { t } = useTranslation() const { t } = useTranslation()
const { relayUrls } = useFeed() const { relayUrls } = useFeed()
const urls = useMemo(() => { const [urls, setUrls] = useState<string[]>([])
if (!parentEvent) return relayUrls
useEffect(() => {
if (!parentEvent) return
const isProtected = isProtectedEvent(parentEvent) const isProtected = isProtectedEvent(parentEvent)
const seenOn = client.getSeenEventRelayUrls(parentEvent.id) const seenOn = client.getSeenEventRelayUrls(parentEvent.id)
if (isProtected && seenOn.length) { if (isProtected && seenOn.length) {
setSpecifiedRelayUrls(seenOn) setSpecifiedRelayUrls(seenOn)
return seenOn setUrls(seenOn)
} else {
setUrls(relayUrls)
} }
return relayUrls
}, [parentEvent, relayUrls]) }, [parentEvent, relayUrls])
if (!urls.length) return null if (!urls.length) return null