import { Skeleton } from '@/components/ui/skeleton'
import { isMentioningMutedUsers, isNip18RepostKind, isNip56ReportEvent } from '@/lib/event'
import ReportCard from '@/components/ReportCard'
import { useContentPolicy } from '@/providers/ContentPolicyProvider'
import { useMuteList } from '@/contexts/mute-list-context'
import { muteSetHas } from '@/lib/mute-set'
import { Event } from 'nostr-tools'
import { memo, useMemo } from 'react'
import MainNoteCard from './MainNoteCard'
import RepostNoteCard from './RepostNoteCard'
const NoteCard = memo(function NoteCard({
event,
className,
filterMutedNotes = true,
pinned = false,
hideParentNotePreview = false,
bottomNoteLabel,
fetchNoteStatsIfMissing = true,
deferAuthorAvatar = true,
searchListPreview = false
}: {
event: Event
className?: string
filterMutedNotes?: boolean
pinned?: boolean
/** When true, hide the parent/root note preview (e.g. when showing quotes of the current note). */
hideParentNotePreview?: boolean
/** Optional label rendered at the bottom of the card (e.g. why this event is in a composed feed). */
bottomNoteLabel?: string
fetchNoteStatsIfMissing?: boolean
deferAuthorAvatar?: boolean
searchListPreview?: boolean
}) {
const { mutePubkeySet } = useMuteList()
const { hideContentMentioningMutedUsers } = useContentPolicy()
const shouldHide = useMemo(() => {
if (filterMutedNotes && muteSetHas(mutePubkeySet, event.pubkey)) {
return true
}
if (hideContentMentioningMutedUsers && isMentioningMutedUsers(event, mutePubkeySet)) {
return true
}
return false
}, [event, filterMutedNotes, mutePubkeySet])
if (shouldHide) return null
if (isNip56ReportEvent(event)) {
return