import ContentPreview from '@/components/ContentPreview' import { FormattedTimestamp } from '@/components/FormattedTimestamp' import StuffStats from '@/components/StuffStats' import TrustScoreBadge from '@/components/TrustScoreBadge' import { Skeleton } from '@/components/ui/skeleton' import UserAvatar from '@/components/UserAvatar' import Username from '@/components/Username' import { NOTIFICATION_LIST_STYLE } from '@/constants' import { toNote, toProfile } from '@/lib/link' import { cn } from '@/lib/utils' import { useSecondaryPage } from '@/PageManager' import { useNostr } from '@/providers/NostrProvider' import { useNotification } from '@/providers/NotificationProvider' import { useUserPreferences } from '@/providers/UserPreferencesProvider' import { NostrEvent } from 'nostr-tools' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' export default function Notification({ icon, notificationId, sender, sentAt, description, middle = null, targetEvent, isNew = false, showStats = false }: { icon: React.ReactNode notificationId: string sender: string sentAt: number description: string middle?: React.ReactNode targetEvent?: NostrEvent isNew?: boolean showStats?: boolean }) { const { t } = useTranslation() const { push } = useSecondaryPage() const { pubkey } = useNostr() const { isNotificationRead, markNotificationAsRead } = useNotification() const { notificationListStyle } = useUserPreferences() const unread = useMemo( () => isNew && !isNotificationRead(notificationId), [isNew, isNotificationRead, notificationId] ) const handleClick = () => { markNotificationAsRead(notificationId) if (targetEvent) { push(toNote(targetEvent.id)) } else if (pubkey) { push(toProfile(pubkey)) } } if (notificationListStyle === NOTIFICATION_LIST_STYLE.COMPACT) { return (