diff options
author | Vitaly Takmazov | 2022-11-20 05:59:45 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:59 +0300 |
commit | 0930332430de0b9f123ecb556949c8db54a92359 (patch) | |
tree | 61eca561df695a48b8ba2d1cd47744e98f14b61d /vnext/src/ui/Thread.js | |
parent | d3cfc10a2087579f44b3bf91576c2f4ca518326a (diff) |
Fix comment/edit/pm
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} />) } |