import ParentNotePreview from '@/components/ParentNotePreview' import { NOTIFICATION_LIST_STYLE } from '@/constants' import { getEmbeddedPubkeys, getParentStuff } from '@/lib/event' import { toExternalContent, toNote } from '@/lib/link' import { useSecondaryPage } from '@/PageManager' import { useNostr } from '@/providers/NostrProvider' import { useUserPreferences } from '@/providers/UserPreferencesProvider' import { AtSign, MessageCircle, Quote } from 'lucide-react' import { Event } from 'nostr-tools' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' import Notification from './Notification' export function MentionNotification({ notification, isNew = false, navIndex }: { notification: Event isNew?: boolean navIndex?: number }) { const { t } = useTranslation() const { push } = useSecondaryPage() const { pubkey } = useNostr() const { notificationListStyle } = useUserPreferences() const isMention = useMemo(() => { if (!pubkey) return false const mentions = getEmbeddedPubkeys(notification) return mentions.includes(pubkey) }, [pubkey, notification]) const { parentEventId, parentExternalContent } = useMemo(() => { return getParentStuff(notification) }, [notification]) return ( ) : parentEventId ? ( ) : ( ) } sender={notification.pubkey} sentAt={notification.created_at} targetEvent={notification} middle={ notificationListStyle === NOTIFICATION_LIST_STYLE.DETAILED && ( { e.stopPropagation() if (parentExternalContent) { push(toExternalContent(parentExternalContent)) } else if (parentEventId) { push(toNote(parentEventId)) } }} /> ) } description={ isMention ? t('mentioned you in a note') : parentEventId ? '' : t('quoted your note') } isNew={isNew} showStats navIndex={navIndex} /> ) }