// @flow import * as React from 'react'; import CardMedia from 'component/cardMedia'; import TruncatedText from 'component/common/truncated-text'; import classnames from 'classnames'; import SubscribeButton from 'component/subscribeButton'; import type { Claim } from 'types/claim'; type Props = { uri: string, isResolvingUri: boolean, isSearchResult: boolean, totalItems: number, size: string, claim: ?Claim, resolveUri: string => void, navigate: (string, ?{}) => void, buttonStyle: string, }; class ChannelTile extends React.PureComponent { static defaultProps = { size: 'regular', }; componentDidMount() { const { uri, resolveUri } = this.props; resolveUri(uri); } componentWillReceiveProps(nextProps: Props) { const { uri, resolveUri } = this.props; if (nextProps.uri !== uri) { resolveUri(uri); } } render() { const { claim, navigate, isResolvingUri, isSearchResult, totalItems, uri, size, buttonStyle, } = this.props; let channelName; let subscriptionUri; if (claim) { channelName = claim.name; subscriptionUri = `lbry://${claim.permanent_url}`; } const onClick = () => navigate('/show', { uri }); return (
{isResolvingUri &&
{__('Loading...')}
} {!isResolvingUri && (
{totalItems > 0 && ( {totalItems} {totalItems === 1 ? 'file' : 'files'} )} {!isResolvingUri && !totalItems && This is an empty channel.}
)} {subscriptionUri && (
)}
); } } export default ChannelTile;