import { Button } from '@/components/ui/button' import { Drawer, DrawerContent, DrawerOverlay } from '@/components/ui/drawer' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/components/ui/dropdown-menu' import { getSharableEventId } from '@/lib/event' import { toNjump } from '@/lib/link' import { pubkeyToNpub } from '@/lib/pubkey' import { useMuteList } from '@/providers/MuteListProvider' import { useNostr } from '@/providers/NostrProvider' import { useScreenSize } from '@/providers/ScreenSizeProvider' import { Bell, BellOff, Code, Copy, Ellipsis, Link } from 'lucide-react' import { Event } from 'nostr-tools' import { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import RawEventDialog from './RawEventDialog' export default function NoteOptions({ event, className }: { event: Event; className?: string }) { const { t } = useTranslation() const { isSmallScreen } = useScreenSize() const { pubkey } = useNostr() const [isRawEventDialogOpen, setIsRawEventDialogOpen] = useState(false) const [isDrawerOpen, setIsDrawerOpen] = useState(false) const { mutePubkeyPublicly, mutePubkeyPrivately, unmutePubkey, mutePubkeys } = useMuteList() const isMuted = useMemo(() => mutePubkeys.includes(event.pubkey), [mutePubkeys, event]) const trigger = ( setIsDrawerOpen(true)} > ) const rawEventDialog = ( setIsRawEventDialogOpen(false)} /> ) if (isSmallScreen) { return ( e.stopPropagation()}> {trigger} setIsDrawerOpen(false)} /> { setIsDrawerOpen(false) navigator.clipboard.writeText(getSharableEventId(event)) }} className="w-full p-6 justify-start text-lg gap-4 [&_svg]:size-5" variant="ghost" > {t('Copy event ID')} { navigator.clipboard.writeText(pubkeyToNpub(event.pubkey) ?? '') setIsDrawerOpen(false) }} className="w-full p-6 justify-start text-lg gap-4 [&_svg]:size-5" variant="ghost" > {t('Copy user ID')} { setIsDrawerOpen(false) navigator.clipboard.writeText(toNjump(getSharableEventId(event))) }} className="w-full p-6 justify-start text-lg gap-4 [&_svg]:size-5" variant="ghost" > {t('Copy share link')} { setIsDrawerOpen(false) setIsRawEventDialogOpen(true) }} className="w-full p-6 justify-start text-lg gap-4 [&_svg]:size-5" variant="ghost" > {t('View raw event')} {pubkey && (isMuted ? ( { setIsDrawerOpen(false) unmutePubkey(event.pubkey) }} className="w-full p-6 justify-start text-destructive text-lg gap-4 [&_svg]:size-5 focus:text-destructive" variant="ghost" > {t('Unmute user')} ) : ( <> { setIsDrawerOpen(false) mutePubkeyPrivately(event.pubkey) }} className="w-full p-6 justify-start text-destructive text-lg gap-4 [&_svg]:size-5 focus:text-destructive" variant="ghost" > {t('Mute user privately')} { setIsDrawerOpen(false) mutePubkeyPublicly(event.pubkey) }} className="w-full p-6 justify-start text-destructive text-lg gap-4 [&_svg]:size-5 focus:text-destructive" variant="ghost" > {t('Mute user publicly')} > ))} {rawEventDialog} ) } return ( e.stopPropagation()}> {trigger} navigator.clipboard.writeText(getSharableEventId(event))} > {t('Copy event ID')} navigator.clipboard.writeText(pubkeyToNpub(event.pubkey) ?? '')} > {t('Copy user ID')} navigator.clipboard.writeText(toNjump(getSharableEventId(event)))} > {t('Copy share link')} setIsRawEventDialogOpen(true)}> {t('View raw event')} {pubkey && ( <> {isMuted ? ( unmutePubkey(event.pubkey)} className="text-destructive focus:text-destructive" > {t('Unmute user')} ) : ( <> mutePubkeyPrivately(event.pubkey)} className="text-destructive focus:text-destructive" > {t('Mute user privately')} mutePubkeyPublicly(event.pubkey)} className="text-destructive focus:text-destructive" > {t('Mute user publicly')} > )} > )} {rawEventDialog} ) }