mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
Fix for message input
This commit is contained in:
parent
4af0172b9a
commit
a26d9da76d
@ -9,11 +9,14 @@ import { useToast } from '@/hooks/useToast';
|
|||||||
const MessageInput = ({ onMessageSent }) => {
|
const MessageInput = ({ onMessageSent }) => {
|
||||||
const [message, setMessage] = useState('');
|
const [message, setMessage] = useState('');
|
||||||
const [collapsed, setCollapsed] = useState(true);
|
const [collapsed, setCollapsed] = useState(true);
|
||||||
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
const { ndk, addSigner } = useNDKContext();
|
const { ndk, addSigner } = useNDKContext();
|
||||||
const { showToast } = useToast();
|
const { showToast } = useToast();
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!message.trim() || !ndk) return;
|
if (!message.trim() || !ndk || isSubmitting) return;
|
||||||
|
|
||||||
|
setIsSubmitting(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!ndk.signer) {
|
if (!ndk.signer) {
|
||||||
@ -32,6 +35,8 @@ const MessageInput = ({ onMessageSent }) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error publishing message:", error);
|
console.error("Error publishing message:", error);
|
||||||
showToast('error', 'Error', 'There was an error sending your message. Please try again.');
|
showToast('error', 'Error', 'There was an error sending your message. Please try again.');
|
||||||
|
} finally {
|
||||||
|
setIsSubmitting(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -70,6 +75,7 @@ const MessageInput = ({ onMessageSent }) => {
|
|||||||
outlined
|
outlined
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
className="w-fit py-2"
|
className="w-fit py-2"
|
||||||
|
disabled={isSubmitting}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user