From a930a277316c99d94907a9418716e3b3eabb8e39 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 4 Feb 2023 06:13:55 +0300 Subject: vnext: hide reply UI for anonymous users --- vnext/src/ui/Comment.js | 44 +++++++++++++------------ vnext/src/ui/Message.js | 85 +++++++++++++++++++++++++------------------------ vnext/src/ui/Thread.js | 2 +- 3 files changed, 68 insertions(+), 63 deletions(-) (limited to 'vnext/src') diff --git a/vnext/src/ui/Comment.js b/vnext/src/ui/Comment.js index 40ce0863..e8fb2afb 100644 --- a/vnext/src/ui/Comment.js +++ b/vnext/src/ui/Comment.js @@ -71,26 +71,28 @@ export default function Comment({ msg, draft, active, setActive, onStartEditing, { active === msg.rid && } -
- { - visitor.uid > 0 ? ( - <> - {active === msg.rid || setActive(msg.rid)}>Reply} - { - visitor.uid == msg.user.uid && - <> -  ·  - onStartEditing(msg)}>Edit - - } - - ) : ( - <> -  · {active === msg.rid || } - - ) - } -
+ {visitor.uid > 0 && +
+ { + visitor.uid > 0 ? ( + <> + {active === msg.rid || setActive(msg.rid)}>Reply} + { + visitor.uid == msg.user.uid && + <> +  ·  + onStartEditing(msg)}>Edit + + } + + ) : ( + <> +  · {active === msg.rid || } + + ) + } +
+ } ); } @@ -99,4 +101,4 @@ export default function Comment({ msg, draft, active, setActive, onStartEditing, */ const linkStyle = { cursor: 'pointer' -}; \ No newline at end of file +}; diff --git a/vnext/src/ui/Message.js b/vnext/src/ui/Message.js index 640512ea..595d2178 100644 --- a/vnext/src/ui/Message.js +++ b/vnext/src/ui/Message.js @@ -31,7 +31,7 @@ import { useVisitor } from './VisitorContext'; * * @param {React.PropsWithChildren<{}> & MessageProps} props props */ -export default function Message({ data, isThread = false, onToggleSubscription, children }) { +export default function Message({ data, isThread, onToggleSubscription, children }) { const [visitor] = useVisitor(); const isCode = (data.tags || []).indexOf('code') >= 0; const likesSummary = data.likes ? `${data.likes}` : 'Recommend'; @@ -54,7 +54,8 @@ export default function Message({ data, isThread = false, onToggleSubscription, } } }, []); - const canComment = data.user && visitor.uid === data.user.uid || !data.ReadOnly; + const canComment = data.user && visitor.uid === data.user.uid || !data.ReadOnly && visitor.uid > 0 + || !data.ReadOnly && !isThread; return (
@@ -98,47 +99,49 @@ export default function Message({ data, isThread = false, onToggleSubscription,
}
- + } {children}
); diff --git a/vnext/src/ui/Thread.js b/vnext/src/ui/Thread.js index 2919e830..f26eead6 100644 --- a/vnext/src/ui/Thread.js +++ b/vnext/src/ui/Thread.js @@ -132,7 +132,7 @@ export default function Thread(props) { { message.mid ? ( - {active === (message.rid || 0) && Write a comment...} + {active === (message.rid || 0) && visitor.uid > 0 && Write a comment...} ) : ( -- cgit v1.2.3