From 853d2a9055672a1cc1e79c6c61427b02dc70b280 Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Sun, 13 Oct 2024 15:55:55 -0500 Subject: [PATCH] Fix message input --- src/components/feeds/MessageInput.js | 25 +++++-------------------- src/pages/feed.js | 3 +-- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/components/feeds/MessageInput.js b/src/components/feeds/MessageInput.js index cf2cc0b..5f3f3b5 100644 --- a/src/components/feeds/MessageInput.js +++ b/src/components/feeds/MessageInput.js @@ -4,35 +4,21 @@ import GenericButton from '@/components/buttons/GenericButton'; import { Panel } from 'primereact/panel'; import { useNDKContext } from "@/context/NDKContext"; import { NDKEvent } from "@nostr-dev-kit/ndk"; -import NDK, { NDKNip07Signer } from "@nostr-dev-kit/ndk"; import { useToast } from '@/hooks/useToast'; -const MessageInput = ({ onMessageSent }) => { +const MessageInput = () => { const [message, setMessage] = useState(''); const [collapsed, setCollapsed] = useState(true); - // todo: revert this after testing phase - // const { ndk, addSigner } = useNDKContext(); - const ndk = new NDK({ - explicitRelayUrls: ["wss://nos.lol/", - "wss://relay.damus.io/", - "wss://relay.snort.social/", - "wss://relay.nostr.band/", - "wss://relay.mutinywallet.com/", - "wss://relay.primal.net/"] - }); + const { ndk, addSigner } = useNDKContext(); const { showToast } = useToast(); const handleSubmit = async () => { if (!message.trim() || !ndk) return; try { - // if (!ndk.signer) { - // await addSigner(); - // } - - const nip07signer = new NDKNip07Signer(); - await ndk.signer?.user(); - ndk.signer = nip07signer; + if (!ndk.signer) { + await addSigner(); + } const event = new NDKEvent(ndk); event.kind = 1; event.content = message; @@ -41,7 +27,6 @@ const MessageInput = ({ onMessageSent }) => { await event.publish(); showToast('success', 'Message Sent', 'Your message has been sent to the PlebDevs community.'); setMessage(''); // Clear the input after successful publish - onMessageSent(); // Call this function to close the accordion } catch (error) { console.error("Error publishing message:", error); showToast('error', 'Error', 'There was an error sending your message. Please try again.'); diff --git a/src/pages/feed.js b/src/pages/feed.js index 5ef33a6..97a2275 100644 --- a/src/pages/feed.js +++ b/src/pages/feed.js @@ -79,8 +79,7 @@ const Feed = () => {