From 0930332430de0b9f123ecb556949c8db54a92359 Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Sun, 20 Nov 2022 05:59:45 +0300
Subject: Fix comment/edit/pm
---
vnext/src/ui/Thread.js | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
(limited to 'vnext/src/ui/Thread.js')
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) {
)) : (
- <>
+ <>
{
Array(loaders).fill().map((it, i) => )
}
--
cgit v1.2.3