import { useSecondaryPage } from '@/PageManager' import { Button } from '@/components/ui/button' import { Skeleton } from '@/components/ui/skeleton' import { useThread } from '@/hooks/useThread' import { getEventKey, isMentioningMutedUsers } from '@/lib/event' import { toNote } from '@/lib/link' import { cn } from '@/lib/utils' import { useContentPolicy } from '@/providers/ContentPolicyProvider' import { useMuteList } from '@/providers/MuteListProvider' import { useScreenSize } from '@/providers/ScreenSizeProvider' import { useUserTrust } from '@/providers/UserTrustProvider' import { Event } from 'nostr-tools' import { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import ClientTag from '../ClientTag' import Collapsible from '../Collapsible' import Content from '../Content' import { FormattedTimestamp } from '../FormattedTimestamp' import Nip05 from '../Nip05' import NoteOptions from '../NoteOptions' import ParentNotePreview from '../ParentNotePreview' import StuffStats from '../StuffStats' import TranslateButton from '../TranslateButton' import TrustScoreBadge from '../TrustScoreBadge' import UserAvatar from '../UserAvatar' import Username from '../Username' export default function ReplyNote({ event, parentEventId, onClickParent = () => {}, highlight = false, className = '' }: { event: Event parentEventId?: string onClickParent?: () => void highlight?: boolean className?: string }) { const { t } = useTranslation() const { isSmallScreen } = useScreenSize() const { push } = useSecondaryPage() const { mutePubkeySet } = useMuteList() const { hideUntrustedInteractions, isUserTrusted } = useUserTrust() const { hideContentMentioningMutedUsers } = useContentPolicy() const eventKey = useMemo(() => getEventKey(event), [event]) const replies = useThread(eventKey) const [showMuted, setShowMuted] = useState(false) const show = useMemo(() => { if (showMuted) { return true } if (mutePubkeySet.has(event.pubkey)) { return false } if (hideContentMentioningMutedUsers && isMentioningMutedUsers(event, mutePubkeySet)) { return false } return true }, [showMuted, mutePubkeySet, event, hideContentMentioningMutedUsers]) const hasReplies = useMemo(() => { if (!replies || replies.length === 0) { return false } for (const reply of replies) { if (hideUntrustedInteractions && !isUserTrusted(reply.pubkey)) { continue } if (mutePubkeySet.has(reply.pubkey)) { continue } if (hideContentMentioningMutedUsers && isMentioningMutedUsers(reply, mutePubkeySet)) { continue } return true } }, [replies]) return (