Fix for message input

This commit is contained in:
austinkelsay 2024-10-13 14:23:10 -05:00
parent 4af0172b9a
commit a26d9da76d

View File

@ -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}
/>
</div>
</Panel>
);
};
export default MessageInput;
export default MessageInput;