import { MAX_PUBLISH_RELAYS } from '@/constants' import { Label } from '@/components/ui/label' import { Slider } from '@/components/ui/slider' import { Switch } from '@/components/ui/switch' import type { TPrePublishRelayCapPreview } from '@/lib/pre-publish-relay-cap' import { cn } from '@/lib/utils' import storage from '@/services/local-storage.service' import type { Event } from 'nostr-tools' import { Dispatch, SetStateAction, useEffect } from 'react' import { useTranslation } from 'react-i18next' import Mentions from './Mentions' import PostRelaySelector from './PostRelaySelector' export type PostEditorAdvancedPanelProps = { show: boolean posting: boolean addClientTag: boolean setAddClientTag: Dispatch> isNsfw: boolean setIsNsfw: Dispatch> minPow: number setMinPow: Dispatch> /** Relay picker + cap hints (hidden for modes that do not pick relays). */ showRelayPicker?: boolean setAdditionalRelayUrls?: Dispatch> onRelayPublishCapChange?: (preview: TPrePublishRelayCapPreview) => void relayParentEvent?: Event relayOpenFrom?: string[] relayContent?: string relayIsPublicMessage?: boolean relayMentions?: string[] relayCapBlockInfo?: { outboxSlotsInPublish: number selectedTotal: number selectedContacted: number } | null discussionThreadRelayError?: string | null isDiscussionThread?: boolean /** Reply / PM mention recipient picker. */ showMentionsPicker?: boolean mentionsContent?: string mentionsParentEvent?: Event mentions?: string[] setMentions?: Dispatch> } export default function PostEditorAdvancedPanel({ show, posting, addClientTag, setAddClientTag, isNsfw, setIsNsfw, minPow, setMinPow, showRelayPicker = false, setAdditionalRelayUrls, onRelayPublishCapChange, relayParentEvent, relayOpenFrom, relayContent = '', relayIsPublicMessage = false, relayMentions = [], relayCapBlockInfo = null, discussionThreadRelayError = null, isDiscussionThread = false, showMentionsPicker = false, mentionsContent = '', mentionsParentEvent, mentions = [], setMentions }: PostEditorAdvancedPanelProps) { const { t } = useTranslation() useEffect(() => { setAddClientTag(storage.getAddClientTag()) }, [setAddClientTag]) if (!show) return null const onAddClientTagChange = (checked: boolean) => { storage.setAddClientTag(checked) setAddClientTag(checked) } return (

{t('Advanced')}

{t('Post editor advanced hint')}

{showMentionsPicker && setMentions ? (
) : null} {showRelayPicker && setAdditionalRelayUrls ? (
{relayCapBlockInfo ? (

{relayCapBlockInfo.outboxSlotsInPublish > 0 ? t('Publish relay cap hint with outbox first', { max: MAX_PUBLISH_RELAYS, reservedSlots: relayCapBlockInfo.outboxSlotsInPublish, selected: relayCapBlockInfo.selectedTotal, selectedContacted: relayCapBlockInfo.selectedContacted }) : t('Publish relay cap hint', { max: MAX_PUBLISH_RELAYS, selected: relayCapBlockInfo.selectedTotal, selectedContacted: relayCapBlockInfo.selectedContacted })}

) : null} {isDiscussionThread && discussionThreadRelayError ? (

{discussionThreadRelayError}

) : null}
) : null}

{t('Show others this was sent via Imwald')}

setMinPow(pow)} max={28} step={1} disabled={posting} />
) }