// @flow import * as ICONS from 'constants/icons'; import React from 'react'; import Comment from 'component/comment'; import Button from 'component/button'; import Spinner from 'component/spinner'; import ChannelThumbnail from 'component/channelThumbnail'; type Props = { fetchedReplies: Array, totalReplies: number, uri: string, parentId: string, claimIsMine: boolean, myChannels: ?Array, linkedCommentId?: string, commentingEnabled: boolean, threadDepth: number, numDirectReplies: number, isFetchingByParentId: { [string]: boolean }, onShowMore?: () => void, }; function CommentsReplies(props: Props) { const { uri, parentId, fetchedReplies, totalReplies, claimIsMine, myChannels, linkedCommentId, commentingEnabled, threadDepth, numDirectReplies, isFetchingByParentId, onShowMore, } = props; const [isExpanded, setExpanded] = React.useState(true); function showMore() { if (onShowMore) { onShowMore(); } } // todo: implement comment_list --mine in SDK so redux can grab with selectCommentIsMine function isMyComment(channelId: string) { if (myChannels != null && channelId != null) { for (let i = 0; i < myChannels.length; i++) { if (myChannels[i].claim_id === channelId) { return true; } } } return false; } const displayedComments = fetchedReplies; return ( Boolean(numDirectReplies) && (
{Boolean(numDirectReplies) && !isExpanded && (
)} {isExpanded && (
)} {isExpanded && fetchedReplies && displayedComments.length < totalReplies && (
)} {isFetchingByParentId[parentId] && (
)}
) ); } export default CommentsReplies;