From f3ec3b0b88a43e2a48db51b81f9b5778ade11248 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sun, 8 Oct 2023 18:45:33 +0300 Subject: Fix initial auth from cookie --- vnext/src/ui/Feeds.js | 1 - vnext/src/ui/Login.js | 4 ++-- vnext/src/ui/Message.js | 8 ++++---- vnext/src/ui/VisitorContext.js | 17 +++++++---------- 4 files changed, 13 insertions(+), 17 deletions(-) (limited to 'vnext/src/ui') diff --git a/vnext/src/ui/Feeds.js b/vnext/src/ui/Feeds.js index bb386e5a..16b6b534 100644 --- a/vnext/src/ui/Feeds.js +++ b/vnext/src/ui/Feeds.js @@ -160,7 +160,6 @@ function Feed({ query }) { const location = useLocation() const [visitor] = useVisitor() const [state, setState] = useState({ - hash: visitor.hash, msgs: [], nextpage: null, error: false, diff --git a/vnext/src/ui/Login.js b/vnext/src/ui/Login.js index 5d9908cb..ed0e990c 100644 --- a/vnext/src/ui/Login.js +++ b/vnext/src/ui/Login.js @@ -23,8 +23,8 @@ function Login({ onAuth }) { const navigate = useNavigate() const [visitor] = useVisitor() useEffect(() => { - if (visitor.hash) { - const {retpath } = location.state || '/' + if (visitor && visitor.hash) { + const retpath = location.state?.retpath || '/' console.log(retpath) navigate(retpath) } diff --git a/vnext/src/ui/Message.js b/vnext/src/ui/Message.js index e4135700..eba0f327 100644 --- a/vnext/src/ui/Message.js +++ b/vnext/src/ui/Message.js @@ -53,7 +53,7 @@ export default function Message({ data, isThread, onToggleSubscription, children } } }, []) - const canComment = data.user && visitor.uid === data.user.uid || !data.ReadOnly && visitor.uid > 0 + const canComment = data.user && visitor && visitor.uid === data.user.uid || !data.ReadOnly && visitor && visitor.uid > 0 || !data.ReadOnly && !isThread return (
@@ -70,7 +70,7 @@ export default function Message({ data, isThread, onToggleSubscription, children { - visitor.uid == data.user.uid && + visitor && visitor.uid == data.user.uid && <>  ·  {canComment &&