diff options
Diffstat (limited to 'vnext/src/ui/Thread.js')
-rw-r--r-- | vnext/src/ui/Thread.js | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/vnext/src/ui/Thread.js b/vnext/src/ui/Thread.js index cfb67bb1..de1d74b2 100644 --- a/vnext/src/ui/Thread.js +++ b/vnext/src/ui/Thread.js @@ -56,15 +56,19 @@ export default function Thread(props) { }); }, [hash, message.mid, mid]); - let postComment = (template) => { - const { body, attach } = template; - let commentAction = editing.rid ? update(mid, editing.rid, body) : comment(mid, active, body, attach); - commentAction.then((res) => { - console.log(res); - setEditing(emptyMessage); - loadReplies(); - }) - .catch(console.log); + let postComment = async ({ body, attach }) => { + try { + let res = editing.rid ? await update(mid, editing.rid, body) + : await comment(mid, active, body, attach); + let result = res.status == 200; + if (result) { + setEditing(emptyMessage); + } + return result; + } catch (e) { + console.error(e); + } + return false; }; let startEditing = (reply) => { @@ -83,6 +87,9 @@ export default function Thread(props) { setReplies(oldReplies => { return [...oldReplies, msg]; }); + setActive(prev => { + return prev + 1; + }); } }; if (props.connection.addEventListener && message.mid) { @@ -119,7 +126,7 @@ export default function Thread(props) { <Comment msg={msg} draft={msg.rid === editing.replyto ? editing.body : ''} active={active} setActive={setActive} onStartEditing={startEditing} postComment={postComment} /> </li> )) : ( - <> + <> { Array(loaders).fill().map((it, i) => <Spinner key={i} />) } |