From abe8e7bc26906929914834dbaf38a793bcbb4f78 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 8 Nov 2022 00:17:14 +0300 Subject: ESLint: switch to `@typescript-eslint/parser` * JS version of the `no-floating-promise` rule sucks :( --- vnext/src/ui/MessageInput.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'vnext/src/ui/MessageInput.js') diff --git a/vnext/src/ui/MessageInput.js b/vnext/src/ui/MessageInput.js index aa4454a1..de4edc7f 100644 --- a/vnext/src/ui/MessageInput.js +++ b/vnext/src/ui/MessageInput.js @@ -89,25 +89,27 @@ export default function MessageInput({ text, rows, placeholder, onSend }) { let uploadValueChanged = (attach) => { setAttach(attach); }; - let onSubmit = async (event) => { + let onSubmit = (event) => { if (event.preventDefault) { event.preventDefault(); } const input = fileinput.current; if (input && input.files) { - if (await onSend({ + onSend({ body: body, attach: attach ? input.files[0] : '' - })) { - setAttach(''); - setBody(''); - if (textareaRef.current) { - textareaRef.current.style.height = ''; + }).then((success) => { + if (success) { + setAttach(''); + setBody(''); + if (textareaRef.current) { + textareaRef.current.style.height = ''; + } + updateFocus(); + } else { + toast('Can not update this message'); } - updateFocus(); - } else { - toast('Can not update this message'); - } + }).catch(console.log); } }; return ( -- cgit v1.2.3