// @flow import React, { useEffect } from 'react'; import { isEmpty } from 'util/object'; import relativeDate from 'tiny-relative-date'; import Button from 'component/button'; import Expandable from 'component/expandable'; import MarkdownPreview from 'component/common/markdown-preview'; import ChannelThumbnail from 'component/channelThumbnail'; type Props = { author: string, authorUri: string, message: string, timePosted: number, claim: ?Claim, pending?: boolean, resolveUri: string => void, isResolvingUri: boolean, channelIsBlocked: boolean, }; const LENGTH_TO_COLLAPSE = 300; function Comment(props: Props) { const { author, authorUri, timePosted, message, pending, claim, isResolvingUri, resolveUri, channelIsBlocked, } = props; // to debounce subsequent requests const shouldFetch = claim === undefined || (claim !== null && claim.value_type === 'channel' && isEmpty(claim.meta) && !pending); useEffect(() => { // If author was extracted from the URI, then it must be valid. if (authorUri && author && !isResolvingUri && shouldFetch) { resolveUri(authorUri); } }, [isResolvingUri, shouldFetch, author, authorUri, resolveUri]); return (