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

View file

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