diff options
Diffstat (limited to 'vnext/src/ui/Post.js')
-rw-r--r-- | vnext/src/ui/Post.js | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/vnext/src/ui/Post.js b/vnext/src/ui/Post.js index 45eceb35..6f7d1e93 100644 --- a/vnext/src/ui/Post.js +++ b/vnext/src/ui/Post.js @@ -1,42 +1,42 @@ -import { useState } from 'react'; -import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; +import { useState } from 'react' +import { useLocation, useNavigate, useSearchParams } from 'react-router-dom' -import Button from './Button'; -import MessageInput from './MessageInput'; +import Button from './Button' +import MessageInput from './MessageInput' -import { post, update } from '../api'; -import { useVisitor } from './VisitorContext'; -import { Helmet } from 'react-helmet'; +import { post, update } from '../api' +import { useVisitor } from './VisitorContext' +import { Helmet } from 'react-helmet' /** * */ export default function Post() { - const location = useLocation(); - const navigate = useNavigate(); - const [visitor] = useVisitor(); - let draftMessage = (location.state || {}).data || {}; - let [draft, setDraft] = useState(draftMessage.body); - let [params] = useSearchParams(); + const location = useLocation() + const navigate = useNavigate() + const [visitor] = useVisitor() + let draftMessage = (location.state || {}).data || {} + let [draft, setDraft] = useState(draftMessage.body) + let [params] = useSearchParams() 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; + 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}`); + const msg = res.data.newMessage + navigate(`/${visitor.uname}/${msg.mid}`) } - return result; + return result } catch (e) { - console.log(e); + console.log(e) } - return false; - }; + return false + } let appendTag = (tag) => { setDraft(prevDraft => { - return `${prevDraft || ''} *${tag} `; - }); - }; + return `${prevDraft || ''} *${tag} ` + }) + } return ( <div className="msg-cont"> <Helmet> @@ -51,12 +51,12 @@ export default function Post() { <p>Tags:</p> { visitor.tagStats.map(t => { - return (<Button key={t.tag} onClick={() => { appendTag(t.tag); }}>{t.tag}</Button>); + return (<Button key={t.tag} onClick={() => { appendTag(t.tag) }}>{t.tag}</Button>) }) } </div> } </div> - ); + ) } |