2022-04-20 16:15:42 +02:00
|
|
|
// @flow
|
2022-05-04 15:20:34 +02:00
|
|
|
import React from 'react';
|
2022-04-20 16:15:42 +02:00
|
|
|
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';
|
2022-05-02 10:43:27 +02:00
|
|
|
import { YRBL_SAD_IMG_URL } from 'config';
|
2022-05-02 12:40:52 +02:00
|
|
|
import Tooltip from 'component/common/tooltip';
|
2022-05-16 08:44:01 +02:00
|
|
|
import useClaimListInfiniteScroll from 'effects/use-claimList-infinite-scroll';
|
2022-04-22 13:16:27 +02:00
|
|
|
|
2022-05-16 08:44:01 +02:00
|
|
|
export const PAGE_SIZE = 30;
|
2022-04-20 16:15:42 +02:00
|
|
|
|
|
|
|
type Props = {
|
2022-05-16 08:44:01 +02:00
|
|
|
historyUris: Array<string>,
|
2022-05-04 12:24:13 +02:00
|
|
|
doClearContentHistoryAll: () => void,
|
2022-05-16 08:44:01 +02:00
|
|
|
doResolveUris: (uris: Array<string>, returnCachedClaims: boolean, resolveReposts: boolean) => void,
|
2022-04-20 16:15:42 +02:00
|
|
|
};
|
|
|
|
|
2022-05-03 13:21:51 +02:00
|
|
|
export default function WatchHistoryPage(props: Props) {
|
2022-05-16 08:44:01 +02:00
|
|
|
const { historyUris, doClearContentHistoryAll, doResolveUris } = props;
|
|
|
|
const { uris, page, isLoadingPage, bumpPage } = useClaimListInfiniteScroll(
|
|
|
|
historyUris,
|
|
|
|
doResolveUris,
|
|
|
|
PAGE_SIZE,
|
|
|
|
true
|
|
|
|
);
|
2022-04-20 16:15:42 +02:00
|
|
|
|
2022-04-26 16:59:40 +02:00
|
|
|
function clearHistory() {
|
2022-05-04 12:24:13 +02:00
|
|
|
doClearContentHistoryAll();
|
2022-04-20 16:15:42 +02:00
|
|
|
}
|
|
|
|
|
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-16 08:44:01 +02:00
|
|
|
{uris.length > 0 && (
|
2022-04-26 16:59:40 +02:00
|
|
|
<Button
|
|
|
|
title={__('Clear History')}
|
|
|
|
button="primary"
|
|
|
|
label={__('Clear History')}
|
|
|
|
onClick={() => clearHistory()}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
2022-04-20 16:15:42 +02:00
|
|
|
</div>
|
2022-05-16 08:44:01 +02:00
|
|
|
{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 && (
|
2022-05-02 10:43:27 +02:00
|
|
|
<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>
|
|
|
|
);
|
2022-04-20 16:15:42 +02:00
|
|
|
}
|