aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/Post.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/ui/Post.js')
-rw-r--r--vnext/src/ui/Post.js23
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 => {