lbry-desktop/ui/page/watchHistory/view.jsx

69 lines
2.1 KiB
React
Raw Normal View History

// @flow
2022-05-04 15:20:34 +02:00
import React from 'react';
import ClaimList from 'component/claimList';
import Page from 'component/page';
import Button from 'component/button';
import classnames from 'classnames';
import Icon from 'component/common/icon';
import * as ICONS from 'constants/icons';
import { YRBL_SAD_IMG_URL } from 'config';
2022-05-02 12:40:52 +02:00
import Tooltip from 'component/common/tooltip';
2022-04-22 13:16:27 +02:00
export const PAGE_VIEW_QUERY = 'view';
type Props = {
2022-05-04 15:20:34 +02:00
history: Array<any>,
2022-05-04 12:24:13 +02:00
doClearContentHistoryAll: () => void,
};
2022-05-03 13:21:51 +02:00
export default function WatchHistoryPage(props: Props) {
2022-05-04 15:20:34 +02:00
const { history, doClearContentHistoryAll } = props;
2022-04-26 16:59:40 +02:00
const [unavailableUris] = React.useState([]);
2022-05-04 15:20:34 +02:00
const watchHistory = [];
for (let entry of history) {
if (entry.uri.indexOf('@') !== -1) {
watchHistory.push(entry.uri);
}
}
2022-04-26 16:59:40 +02:00
function clearHistory() {
2022-05-04 12:24:13 +02:00
doClearContentHistoryAll();
}
2022-04-26 16:59:40 +02:00
return (
<Page className="historyPage-wrapper">
<div className={classnames('section card-stack')}>
<div className="claim-list__header">
<h1 className="card__title">
2022-05-03 13:21:51 +02:00
<Icon icon={ICONS.WATCH_HISTORY} style={{ marginRight: 'var(--spacing-s)' }} />
2022-04-26 16:59:40 +02:00
{__('Watch History')}
2022-05-02 13:13:47 +02:00
<Tooltip title={__('Currently, your watch history is only saved locally.')}>
2022-05-02 12:40:52 +02:00
<Button className="icon--help" icon={ICONS.HELP} iconSize={14} />
</Tooltip>
2022-04-26 16:59:40 +02:00
</h1>
<div className="claim-list__alt-controls--wrap">
2022-05-03 13:21:51 +02:00
{watchHistory.length > 0 && (
2022-04-26 16:59:40 +02:00
<Button
title={__('Clear History')}
button="primary"
label={__('Clear History')}
onClick={() => clearHistory()}
/>
)}
</div>
</div>
2022-05-04 12:36:48 +02:00
{watchHistory.length > 0 && <ClaimList uris={watchHistory} unavailableUris={unavailableUris} inWatchHistory />}
2022-05-03 13:21:51 +02:00
{watchHistory.length === 0 && (
<div style={{ textAlign: 'center' }}>
<img src={YRBL_SAD_IMG_URL} />
<h2 className="main--empty empty" style={{ marginTop: '0' }}>
{__('Nothing here')}
</h2>
</div>
)}
2022-04-26 16:59:40 +02:00
</div>
</Page>
);
}