aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/ui/Message.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/ui/Message.js')
-rw-r--r--vnext/src/ui/Message.js85
1 files changed, 44 insertions, 41 deletions
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 (
<div className="msg-cont">
<Recommendations forMessage={data} />
@@ -98,47 +99,49 @@ export default function Message({ data, isThread = false, onToggleSubscription,
</div>
}
<div className="embedContainer" ref={embedRef} />
- <nav className="l">
- {data.user && visitor.uid === data.user.uid ? (
- <Link to={`/${data.user.uname}/${data.mid}`} className="a-like msg-button"
- state={{ data: data }}>
- <Icon name="ei-heart" size="s" />
- <span>{likesSummary}</span>
- </Link>
- ) : visitor.uid > 0 ? (
- <Link to={'/post'} className="a-like msg-button">
- <Icon name="ei-heart" size="s" />
- <span>{likesSummary}</span>
- </Link>
- ) : (
- <Link to="/login" className="a-login msg-button">
- <Icon name="ei-heart" size="s" />
- <span>{likesSummary}</span>
- </Link>
- )}
- {
- data.user && canComment && ((
- isThread ? (
+ {canComment &&
+ <nav className="l">
+ {data.user && visitor.uid === data.user.uid ? (
+ <Link to={`/${data.user.uname}/${data.mid}`} className="a-like msg-button"
+ state={{ data: data }}>
+ <Icon name="ei-heart" size="s" />
+ <span>{likesSummary}</span>
+ </Link>
+ ) : visitor.uid > 0 ? (
+ <Link to={'/post'} className="a-like msg-button">
+ <Icon name="ei-heart" size="s" />
+ <span>{likesSummary}</span>
+ </Link>
+ ) : (
+ <Link to="/login" className="a-login msg-button">
+ <Icon name="ei-heart" size="s" />
+ <span>{likesSummary}</span>
+ </Link>
+ )}
+ {
+ data.user && canComment && ((
+ isThread ? (
<a className="msg-button" onClick={() => { onToggleSubscription(data); }}>
- {
- data.subscribed ? (<>
- <Icon name="ei-check" size="s" />
- <span>Subscribed</span>
- </>) : (<>
- <Icon name="ei-eye" size="s" />
- <span>Subscribe</span>
- </>)}
+ {
+ data.subscribed ? (<>
+ <Icon name="ei-check" size="s" />
+ <span>Subscribed</span>
+ </>) : (<>
+ <Icon name="ei-eye" size="s" />
+ <span>Subscribe</span>
+ </>)}
</a>
- ) : (
- <Link to={`/${data.user.uname}/${data.mid}`} className="a-comment msg-button"
- state={{ data: data }}>
- <Icon name="ei-comment" size="s" />
- <span>{commentsSummary}</span>
- </Link>
- )
- ))
- }
- </nav>
+ ) : (
+ <Link to={`/${data.user.uname}/${data.mid}`} className="a-comment msg-button"
+ state={{ data: data }}>
+ <Icon name="ei-comment" size="s" />
+ <span>{commentsSummary}</span>
+ </Link>
+ )
+ ))
+ }
+ </nav>
+ }
{children}
</div >
);