diff --git a/src/components/note/form/basic.tsx b/src/components/note/form/basic.tsx index f4d7166e..60651075 100644 --- a/src/components/note/form/basic.tsx +++ b/src/components/note/form/basic.tsx @@ -3,7 +3,7 @@ import { RelayContext } from '@components/contexts/relay'; import { dateToUnix } from '@utils/getDate'; import * as Dialog from '@radix-ui/react-dialog'; -import { ImageIcon, SizeIcon } from '@radix-ui/react-icons'; +import { SizeIcon } from '@radix-ui/react-icons'; import { useLocalStorage } from '@rehooks/local-storage'; import * as commands from '@uiw/react-md-editor/lib/commands'; import dynamic from 'next/dynamic'; diff --git a/src/components/note/form/comment.tsx b/src/components/note/form/comment.tsx new file mode 100644 index 00000000..6fb50199 --- /dev/null +++ b/src/components/note/form/comment.tsx @@ -0,0 +1,175 @@ +import { RelayContext } from '@components/contexts/relay'; +import { ImageWithFallback } from '@components/imageWithFallback'; + +import { dateToUnix } from '@utils/getDate'; + +import * as Dialog from '@radix-ui/react-dialog'; +import { SizeIcon } from '@radix-ui/react-icons'; +import { useLocalStorage } from '@rehooks/local-storage'; +import * as commands from '@uiw/react-md-editor/lib/commands'; +import dynamic from 'next/dynamic'; +import { getEventHash, signEvent } from 'nostr-tools'; +import { useContext, useState } from 'react'; + +const MDEditor = dynamic(() => import('@uiw/react-md-editor').then((mod) => mod.default), { + ssr: false, +}); + +export default function FormComment() { + const relayPool: any = useContext(RelayContext); + const [relays]: any = useLocalStorage('relays'); + + const [value, setValue] = useState(''); + + const [currentUser]: any = useLocalStorage('current-user'); + const pubkey = currentUser.id; + const privkey = currentUser.privkey; + const profile = JSON.parse(currentUser.metadata); + + const postButton = { + name: 'post', + keyCommand: 'post', + buttonProps: { className: 'cta-btn', 'aria-label': 'Post a message' }, + icon: ( +
+ + Post + + +
+ ), + execute: (state: { text: any }) => { + const message = state.text; + + if (message.length > 0) { + const event: any = { + content: message, + created_at: dateToUnix(), + kind: 1, + pubkey: pubkey, + tags: [], + }; + event.id = getEventHash(event); + event.sig = signEvent(event, privkey); + + relayPool.publish(event, relays); + setValue(''); + } + }, + }; + + return ( + +
+
+
+
+ +
+
+
+
+