fix comment redirect for unauth users

This commit is contained in:
Sean Yesmunt 2020-08-27 16:16:23 -04:00
parent 37383953fa
commit b26b143c31
2 changed files with 3 additions and 33 deletions

View file

@ -9,12 +9,10 @@ import { FormField, Form } from 'component/common/form';
import Button from 'component/button';
import ChannelSelection from 'component/selectChannel';
import usePersistedState from 'effects/use-persisted-state';
import I18nMessage from 'component/i18nMessage';
import { FF_MAX_CHARS_IN_COMMENT } from 'constants/form-field';
import { useHistory } from 'react-router';
type Props = {
commentingEnabled: boolean,
uri: string,
claim: StreamClaim,
openModal: (id: string, { onCommentAcknowledge: () => void }) => void,
@ -27,17 +25,7 @@ type Props = {
};
export function CommentCreate(props: Props) {
const {
commentingEnabled,
createComment,
claim,
openModal,
channels,
parentId,
onDoneReplying,
onCancelReplying,
isNested,
} = props;
const { createComment, claim, openModal, channels, parentId, onDoneReplying, onCancelReplying, isNested } = props;
const { push } = useHistory();
const { claim_id: claimId } = claim;
const isReply = !!parentId;
@ -100,14 +88,6 @@ export function CommentCreate(props: Props) {
useEffect(() => setCharCount(commentValue.length), [commentValue]);
if (!commentingEnabled) {
return (
<I18nMessage tokens={{ sign_in_link: <Button button="link" requiresAuth label={__('log in')} /> }}>
Please %sign_in_link% to comment.
</I18nMessage>
);
}
if (!hasChannels) {
return (
<div role="button" onClick={() => push(`/$/${PAGES.CHANNEL_NEW}`)}>

View file

@ -15,20 +15,10 @@ type Props = {
myChannels: ?Array<ChannelClaim>,
isFetchingComments: boolean,
linkedComment: any,
commentingEnabled: boolean,
};
function CommentList(props: Props) {
const {
fetchComments,
uri,
comments,
claimIsMine,
myChannels,
isFetchingComments,
linkedComment,
commentingEnabled,
} = props;
const { fetchComments, uri, comments, claimIsMine, myChannels, isFetchingComments, linkedComment } = props;
const linkedCommentId = linkedComment && linkedComment.comment_id;
const [start] = React.useState(0);
@ -93,7 +83,7 @@ function CommentList(props: Props) {
title={<span>{__('Comments')}</span>}
actions={
<>
{commentingEnabled && <CommentCreate uri={uri} />}
<CommentCreate uri={uri} />
{!isFetchingComments && hasNoComments && <div className="main--empty">{__('Be the first to comment!')}</div>}
<ul className="comments" ref={commentRef}>
{isFetchingComments && (