// @flow import * as React from 'react'; import CardMedia from 'component/cardMedia'; import TruncatedText from 'component/common/truncated-text'; /* This component can probably be combined with FileTile Currently the only difference is showing the number of files/empty channel */ type Props = { uri: string, isResolvingUri: boolean, totalItems: number, claim: ?{ claim_id: string, name: string, }, resolveUri: string => void, navigate: (string, ?{}) => void, }; class ChannelTile extends React.PureComponent { 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, totalItems, uri } = this.props; let channelName, channelId; if (claim) { channelName = claim.name; channelId = claim.claim_id; } const onClick = () => navigate('/show', { uri }); return (
{isResolvingUri &&
{__('Loading...')}
} {!isResolvingUri && (
{channelName || uri}
{totalItems > 0 && ( {totalItems} {totalItems === 1 ? 'file' : 'files'} )} {!isResolvingUri && !totalItems && This is an empty channel.}
)}
); } } export default ChannelTile;