import { ImageWithFallback } from '@components/imageWithFallback'; import { RelayContext } from '@components/relaysProvider'; import { UserExtend } from '@components/user/extend'; import { dateToUnix } from '@utils/getDate'; import * as Dialog from '@radix-ui/react-dialog'; import useLocalStorage from '@rehooks/local-storage'; import { MultiBubble, OpenNewWindow } from 'iconoir-react'; import { useRouter } from 'next/navigation'; import { getEventHash, signEvent } from 'nostr-tools'; import { useContext, useState } from 'react'; export const NoteComment = ({ count, eventID, eventPubkey, eventContent, eventTime, }: { count: number; eventID: string; eventPubkey: string; eventTime: number; eventContent: any; }) => { const router = useRouter(); const [pool, relays]: any = useContext(RelayContext); const [open, setOpen] = useState(false); const [value, setValue] = useState(''); const [activeAccount]: any = useLocalStorage('activeAccount', {}); const profile = activeAccount.metadata ? JSON.parse(activeAccount.metadata) : null; const openThread = () => { router.push(`/newsfeed/${eventID}`); }; const submitEvent = () => { const event: any = { content: value, created_at: dateToUnix(), kind: 1, pubkey: activeAccount.pubkey, tags: [['e', eventID]], }; event.id = getEventHash(event); event.sig = signEvent(event, activeAccount.privkey); pool.publish(event, relays); setOpen(false); }; return (
{/* root note */}
{eventContent}
{/* divider */}
{/* comment form */}