diff --git a/src/components/PostEditor/NormalPostContent.tsx b/src/components/PostEditor/NormalPostContent.tsx index 226c8a1a..f90ca1c0 100644 --- a/src/components/PostEditor/NormalPostContent.tsx +++ b/src/components/PostEditor/NormalPostContent.tsx @@ -1,10 +1,8 @@ import { Button } from '@/components/ui/button' import { useToast } from '@/hooks/use-toast' import { createCommentDraftEvent, createShortTextNoteDraftEvent } from '@/lib/draft-event' -import { useFeed } from '@/providers/FeedProvider.tsx' import { useNostr } from '@/providers/NostrProvider' import client from '@/services/client.service' -import relayInfoService from '@/services/relay-info.service' import { ChevronDown, ImageUp, LoaderCircle } from 'lucide-react' import { Event, kinds } from 'nostr-tools' import { useState } from 'react' @@ -14,7 +12,6 @@ import Mentions from './Mentions' import PostOptions from './PostOptions.tsx' import Preview from './Preview' import SendOnlyToSwitch from './SendOnlyToSwitch.tsx' -import { TPostOptions } from './types.ts' import Uploader from './Uploader' export default function NormalPostContent({ @@ -29,12 +26,12 @@ export default function NormalPostContent({ const { t } = useTranslation() const { toast } = useToast() const { publish, checkLogin } = useNostr() - const { relayUrls } = useFeed() const [content, setContent] = useState(defaultContent) const [pictureInfos, setPictureInfos] = useState<{ url: string; tags: string[][] }[]>([]) const [posting, setPosting] = useState(false) const [showMoreOptions, setShowMoreOptions] = useState(false) - const [postOptions, setPostOptions] = useState({}) + const [addClientTag, setAddClientTag] = useState(false) + const [specifiedRelayUrls, setSpecifiedRelayUrls] = useState(undefined) const [uploadingPicture, setUploadingPicture] = useState(false) const canPost = !!content && !posting @@ -53,25 +50,20 @@ export default function NormalPostContent({ const relayList = await client.fetchRelayList(parentEvent.pubkey) additionalRelayUrls.push(...relayList.read.slice(0, 5)) } - let protectedEvent = false - if (postOptions.sendOnlyToCurrentRelays) { - const relayInfos = await relayInfoService.getRelayInfos(relayUrls) - protectedEvent = relayInfos.every((info) => info?.supported_nips?.includes(70)) - } const draftEvent = parentEvent && parentEvent.kind !== kinds.ShortTextNote ? await createCommentDraftEvent(content, parentEvent, pictureInfos, { - addClientTag: postOptions.addClientTag, - protectedEvent + addClientTag, + protectedEvent: !!specifiedRelayUrls }) : await createShortTextNoteDraftEvent(content, pictureInfos, { parentEvent, - addClientTag: postOptions.addClientTag, - protectedEvent + addClientTag, + protectedEvent: !!specifiedRelayUrls }) await publish(draftEvent, { additionalRelayUrls, - specifiedRelayUrls: postOptions.sendOnlyToCurrentRelays ? relayUrls : undefined + specifiedRelayUrls }) setContent('') close() @@ -114,8 +106,8 @@ export default function NormalPostContent({ {content && }
@@ -163,8 +155,8 @@ export default function NormalPostContent({