2019-06-11 20:10:58 +02:00
|
|
|
// @flow
|
|
|
|
import * as icons from 'constants/icons';
|
|
|
|
import * as React from 'react';
|
|
|
|
import { parseURI } from 'lbry-redux';
|
|
|
|
import Icon from 'component/common/icon';
|
|
|
|
import FilePrice from 'component/filePrice';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
2019-06-27 08:18:45 +02:00
|
|
|
claim: ?StreamClaim,
|
2019-06-11 20:10:58 +02:00
|
|
|
downloaded: boolean,
|
|
|
|
claimIsMine: boolean,
|
|
|
|
isSubscribed: boolean,
|
|
|
|
isNew: boolean,
|
|
|
|
rewardedContentClaimIds: Array<string>,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function FileProperties(props: Props) {
|
2019-06-27 08:18:45 +02:00
|
|
|
const { claim, uri, downloaded, claimIsMine, rewardedContentClaimIds, isSubscribed } = props;
|
2019-06-11 20:10:58 +02:00
|
|
|
const { claimId } = parseURI(uri);
|
|
|
|
const isRewardContent = rewardedContentClaimIds.includes(claimId);
|
|
|
|
|
2019-06-27 08:18:45 +02:00
|
|
|
const video = claim && claim.value && claim.value.video;
|
|
|
|
let duration;
|
|
|
|
if (video && video.duration) {
|
|
|
|
// $FlowFixMe
|
|
|
|
let date = new Date(null);
|
|
|
|
date.setSeconds(video.duration);
|
|
|
|
let timeString = date.toISOString().substr(11, 8);
|
|
|
|
|
|
|
|
if (timeString.startsWith('00:')) {
|
|
|
|
timeString = timeString.substr(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
duration = timeString;
|
|
|
|
}
|
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
return (
|
|
|
|
<div className="file-properties">
|
2019-06-28 09:27:55 +02:00
|
|
|
{isSubscribed && <Icon tooltip icon={icons.SUBSCRIPTION} />}
|
|
|
|
{!claimIsMine && downloaded && <Icon tooltip icon={icons.DOWNLOAD} />}
|
|
|
|
{isRewardContent && <Icon tooltip icon={icons.FEATURED} />}
|
2019-06-11 20:10:58 +02:00
|
|
|
<FilePrice hideFree uri={uri} />
|
2019-06-27 08:18:45 +02:00
|
|
|
{duration && <span className="media__subtitle">{duration}</span>}
|
2019-06-11 20:10:58 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|