import { NDKKind } from '@nostr-dev-kit/ndk'; import * as AlertDialog from '@radix-ui/react-alert-dialog'; import * as Tooltip from '@radix-ui/react-tooltip'; import { message } from '@tauri-apps/plugin-dialog'; import { useState } from 'react'; import { twMerge } from 'tailwind-merge'; import { useNDK } from '@libs/ndk/provider'; import { LoaderIcon, RepostIcon } from '@shared/icons'; import { useNostr } from '@utils/hooks/useNostr'; import { sendNativeNotification } from '@utils/notification'; export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) { const { publish } = useNostr(); const { relayUrls } = useNDK(); const [open, setOpen] = useState(false); const [isLoading, setIsLoading] = useState(false); const [isRepost, setIsRepost] = useState(false); const submit = async () => { setIsLoading(true); const tags = [ ['e', id, relayUrls[0], 'root'], ['p', pubkey], ]; const event = await publish({ content: '', kind: NDKKind.Repost, tags: tags }); if (event) { setOpen(false); setIsRepost(true); await sendNativeNotification('Reposted successfully', 'Lume'); } else { setIsLoading(false); await message('Repost failed, try again later', { title: 'Lume', type: 'error' }); } }; return ( Repost
Confirm repost this post? Reposted post will be visible to your followers, and you cannot undo this action.
); }