From a26d9da76df9fc90a79eaeae1c6233592a30f37a Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Sun, 13 Oct 2024 14:23:10 -0500 Subject: [PATCH] Fix for message input --- src/components/feeds/MessageInput.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/feeds/MessageInput.js b/src/components/feeds/MessageInput.js index ac051dc..2a6a610 100644 --- a/src/components/feeds/MessageInput.js +++ b/src/components/feeds/MessageInput.js @@ -9,11 +9,14 @@ import { useToast } from '@/hooks/useToast'; const MessageInput = ({ onMessageSent }) => { const [message, setMessage] = useState(''); const [collapsed, setCollapsed] = useState(true); + const [isSubmitting, setIsSubmitting] = useState(false); const { ndk, addSigner } = useNDKContext(); const { showToast } = useToast(); const handleSubmit = async () => { - if (!message.trim() || !ndk) return; + if (!message.trim() || !ndk || isSubmitting) return; + + setIsSubmitting(true); try { if (!ndk.signer) { @@ -32,6 +35,8 @@ const MessageInput = ({ onMessageSent }) => { } catch (error) { console.error("Error publishing message:", error); showToast('error', 'Error', 'There was an error sending your message. Please try again.'); + } finally { + setIsSubmitting(false); } }; @@ -70,10 +75,11 @@ const MessageInput = ({ onMessageSent }) => { outlined onClick={handleSubmit} className="w-fit py-2" + disabled={isSubmitting} /> ); }; -export default MessageInput; \ No newline at end of file +export default MessageInput;