/* eslint-disable @typescript-eslint/no-explicit-any */ import { currentUser } from '@stores/currentUser'; import { useStore } from '@nanostores/react'; import * as Dialog from '@radix-ui/react-dialog'; import * as commands from '@uiw/react-md-editor/lib/commands'; import dynamic from 'next/dynamic'; import { dateToUnix, useNostr } from 'nostr-react'; import { getEventHash, signEvent } from 'nostr-tools'; import { useState } from 'react'; const MDEditor = dynamic(() => import('@uiw/react-md-editor').then((mod) => mod.default), { ssr: false, }); export default function CreatePost() { const { publish } = useNostr(); const [value, setValue] = useState(''); const $currentUser: any = useStore(currentUser); const pubkey = $currentUser.pubkey; const privkey = $currentUser.privkey; 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); publish(event); setValue(''); } }, }; return (