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

80 lines
2.5 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';
import useClaimListInfiniteScroll from 'effects/use-claimList-infinite-scroll';
2022-04-22 13:16:27 +02:00
export const PAGE_SIZE = 30;
type Props = {
historyUris: Array<string>,
2022-05-04 12:24:13 +02:00
doClearContentHistoryAll: () => void,
doResolveUris: (uris: Array<string>, returnCachedClaims: boolean, resolveReposts: boolean) => void,
};
2022-05-03 13:21:51 +02:00
export default function WatchHistoryPage(props: Props) {
const { historyUris, doClearContentHistoryAll, doResolveUris } = props;
const { uris, page, isLoadingPage, bumpPage } = useClaimListInfiniteScroll(
historyUris,
doResolveUris,
PAGE_SIZE,
true
);
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">
{uris.length > 0 && (
2022-04-26 16:59:40 +02:00
<Button
title={__('Clear History')}
button="primary"
label={__('Clear History')}
onClick={() => clearHistory()}
/>
)}
</div>
</div>
{uris.length > 0 && (
<ClaimList
uris={uris.slice(0, (page + 1) * PAGE_SIZE)}
onScrollBottom={bumpPage}
page={page + 1}
pageSize={PAGE_SIZE}
loading={isLoadingPage}
useLoadingSpinner
inWatchHistory
/>
)}
{uris.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>
);
}