From 8887e1b51565b992f34c955c459125eb85b28483 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 31 Oct 2022 22:48:30 +0300 Subject: `useVisitor` hook --- vnext/src/ui/Thread.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'vnext/src/ui/Thread.js') diff --git a/vnext/src/ui/Thread.js b/vnext/src/ui/Thread.js index 5c9412d6..b2d17824 100644 --- a/vnext/src/ui/Thread.js +++ b/vnext/src/ui/Thread.js @@ -7,6 +7,7 @@ import MessageInput from './MessageInput'; import Spinner from './Spinner'; import { getMessages, comment, update } from '../api'; +import { useVisitor } from './VisitorContext'; /** * @type { import('../api').Message } */ @@ -14,7 +15,6 @@ const emptyMessage = {}; /** * @param {{ - visitor: import('../api').SecureUser connection: EventSource? }} props */ @@ -27,7 +27,8 @@ export default function Thread(props) { const [active, setActive] = useState(0); const [editing, setEditing] = useState(emptyMessage); - const [hash] = useState(props.visitor.hash); + const [visitor] = useVisitor(); + const [hash] = useState(visitor.hash); const { mid } = params; let loadReplies = useCallback(() => { @@ -97,7 +98,7 @@ export default function Thread(props) { <> { message.mid ? ( - + {active === (message.rid || 0) && Write a comment...} ) : ( @@ -109,7 +110,7 @@ export default function Thread(props) { { !loading ? replies.map((msg) => (
  • - +
  • )) : ( <> -- cgit v1.2.3