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/Post.js | |
parent | d3cfc10a2087579f44b3bf91576c2f4ca518326a (diff) |
Fix comment/edit/pm
Diffstat (limited to 'vnext/src/ui/Post.js')
-rw-r--r-- | vnext/src/ui/Post.js | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/vnext/src/ui/Post.js b/vnext/src/ui/Post.js index 8fc753b4..45eceb35 100644 --- a/vnext/src/ui/Post.js +++ b/vnext/src/ui/Post.js @@ -18,16 +18,19 @@ export default function Post() { let draftMessage = (location.state || {}).data || {}; let [draft, setDraft] = useState(draftMessage.body); let [params] = useSearchParams(); - let postMessage = (template) => { - const { attach, body } = template; - const postAction = draftMessage.mid ? update(draftMessage.mid, 0, body) : post(body, attach); - postAction - .then(response => { - if (response.status === 200) { - const msg = response.data.newMessage; - navigate(`/${visitor.uname}/${msg.mid}`); - } - }).catch(console.log); + let postMessage = async ({ attach, body }) => { + try { + const res = draftMessage.mid ? await update(draftMessage.mid, 0, body) : await post(body, attach); + let result = res.status == 200; + if (result) { + const msg = res.data.newMessage; + navigate(`/${visitor.uname}/${msg.mid}`); + } + return result; + } catch (e) { + console.log(e); + } + return false; }; let appendTag = (tag) => { setDraft(prevDraft => { |