add lastViewed prop to <FileCard>

This commit is contained in:
Travis Eden 2018-08-01 10:45:13 -04:00 committed by Sean Yesmunt
parent 86a40eacbc
commit 9bd0a32b99
2 changed files with 9 additions and 1 deletions

View file

@ -1,5 +1,6 @@
// @flow
import * as React from 'react';
import moment from 'moment';
import { normalizeURI, convertToShareLink } from 'lbry-redux';
import type { Claim, Metadata } from 'types/claim';
import CardMedia from 'component/cardMedia';
@ -24,6 +25,7 @@ type Props = {
showPrice: boolean,
pending?: boolean,
position: ?number,
lastViewed: ?number,
/* eslint-disable react/no-unused-prop-types */
resolveUri: string => void,
isResolvingUri: boolean,
@ -63,6 +65,7 @@ class FileCard extends React.PureComponent<Props> {
showPrice,
pending,
position,
lastViewed,
} = this.props;
const shouldHide = !claimIsMine && !pending && obscureNsfw && metadata && metadata.nsfw;
@ -107,6 +110,9 @@ class FileCard extends React.PureComponent<Props> {
{fileInfo && <Icon icon={icons.LOCAL} />}
{position && <Icon icon={icons.REFRESH} />}
</div>
{lastViewed && (
<div className="card__subtitle">{moment(lastViewed).from(moment())}</div>
)}
</div>
</section>
);

View file

@ -47,7 +47,9 @@ class UserHistoryPage extends React.PureComponent<Props> {
<div className="card__list">
{history && history.length ? (
<React.Fragment>
{history.map(item => <FileCard key={item.uri} uri={item.uri} />)}
{history.map(item => (
<FileCard key={item.uri} uri={item.uri} lastViewed={item.lastViewed} />
))}
{pageCount > 1 && (
<FormRow verticallyCentered centered>
<ReactPaginate