feat: add try-delete post option

This commit is contained in:
codytseng 2025-08-30 14:21:35 +08:00
parent 905ef99e0e
commit 13527a3ca7
21 changed files with 241 additions and 97 deletions

View file

@ -6,7 +6,7 @@ import { useFavoriteRelays } from '@/providers/FavoriteRelaysProvider'
import { useMuteList } from '@/providers/MuteListProvider'
import { useNostr } from '@/providers/NostrProvider'
import client from '@/services/client.service'
import { Bell, BellOff, Code, Copy, Link, Mail, SatelliteDish, Server } from 'lucide-react'
import { Bell, BellOff, Code, Copy, Link, Mail, SatelliteDish, Server, Trash2 } from 'lucide-react'
import { Event } from 'nostr-tools'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
@ -45,7 +45,7 @@ export function useMenuActions({
isSmallScreen
}: UseMenuActionsProps) {
const { t } = useTranslation()
const { pubkey, relayList } = useNostr()
const { pubkey, relayList, attemptDelete } = useNostr()
const { relaySets, favoriteRelays } = useFavoriteRelays()
const { mutePubkeyPublicly, mutePubkeyPrivately, unmutePubkey, mutePubkeys } = useMuteList()
const isMuted = useMemo(() => mutePubkeys.includes(event.pubkey), [mutePubkeys, event])
@ -235,6 +235,19 @@ export function useMenuActions({
}
}
if (pubkey && event.pubkey === pubkey) {
actions.push({
icon: Trash2,
label: t('Try deleting this note'),
onClick: () => {
closeDrawer()
attemptDelete(event)
},
className: 'text-destructive focus:text-destructive',
separator: true
})
}
return actions
}, [
t,