// @flow import React from 'react'; import moment from 'moment'; import classnames from 'classnames'; import Button from 'component/button'; import { FormField } from 'component/common/form'; import { withRouter } from 'react-router-dom'; import { formatLbryUrlForWeb } from 'util/url'; type Props = { lastViewed: number, uri: string, claim: ?StreamClaim, selected: boolean, onSelect?: () => void, resolveUri: string => void, slim: boolean, history: { push: string => void }, }; class NavigationHistoryItem extends React.PureComponent { static defaultProps = { slim: false, }; componentDidMount() { const { claim, uri, resolveUri } = this.props; if (!claim) { resolveUri(uri); } } render() { const { lastViewed, selected, onSelect, claim, uri, slim, history } = this.props; let title; if (claim && claim.value) { ({ title } = claim.value); } const navigatePath = formatLbryUrlForWeb(uri); const onClick = onSelect || function() { history.push(navigatePath); }; return (
{!slim && } {moment(lastViewed).from(moment())}
); } } export default withRouter(NavigationHistoryItem);