import { Label } from '@/components/ui/label' import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover' import { Switch } from '@/components/ui/switch' import { isProtectedEvent } from '@/lib/event' import { simplifyUrl } from '@/lib/url' import { useFeed } from '@/providers/FeedProvider' import { Info } from 'lucide-react' import { Event } from 'nostr-tools' import { Dispatch, SetStateAction, useEffect } from 'react' import { useTranslation } from 'react-i18next' import { TPostOptions } from './types' export default function SendOnlyToSwitch({ parentEvent, postOptions, setPostOptions }: { parentEvent?: Event postOptions: TPostOptions setPostOptions: Dispatch> }) { const { t } = useTranslation() const { relayUrls } = useFeed() useEffect(() => { const isProtected = parentEvent ? isProtectedEvent(parentEvent) : false if (isProtected) { setPostOptions((prev) => ({ ...prev, sendOnlyToCurrentRelays: true })) } }, []) return (
{relayUrls.length > 1 && ( {relayUrls.map((url) => (
{simplifyUrl(url)}
))}
)}
setPostOptions((prev) => ({ ...prev, sendOnlyToCurrentRelays: checked })) } />
) }