2022-04-20 16:15:42 +02:00
|
|
|
// @flow
|
|
|
|
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';
|
2022-05-02 10:43:27 +02:00
|
|
|
import { YRBL_SAD_IMG_URL } from 'config';
|
2022-04-20 16:15:42 +02:00
|
|
|
|
2022-04-22 13:16:27 +02:00
|
|
|
import usePersistedState from 'effects/use-persisted-state';
|
|
|
|
|
2022-04-20 16:15:42 +02:00
|
|
|
export const PAGE_VIEW_QUERY = 'view';
|
2022-04-26 16:59:40 +02:00
|
|
|
// export const EDIT_PAGE = 'edit';
|
2022-04-20 16:15:42 +02:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
collectionId: string,
|
|
|
|
claim: Claim,
|
|
|
|
title: string,
|
|
|
|
thumbnail: string,
|
|
|
|
collectionUrls: Array<string>,
|
|
|
|
isResolvingCollection: boolean,
|
2022-04-26 16:59:40 +02:00
|
|
|
// isMyClaim: boolean,
|
|
|
|
// isMyCollection: boolean,
|
|
|
|
// claimIsPending: boolean,
|
|
|
|
// collectionHasEdits: boolean,
|
|
|
|
// deleteCollection: (string, string) => void,
|
|
|
|
// editCollection: (string, CollectionEditParams) => void,
|
2022-04-20 16:15:42 +02:00
|
|
|
fetchCollectionItems: (string, () => void) => void,
|
|
|
|
resolveUris: (string) => void,
|
|
|
|
user: ?User,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default function HistoryPage(props: Props) {
|
2022-04-26 16:59:40 +02:00
|
|
|
const { collectionId } = props;
|
|
|
|
const [history, setHistory] = usePersistedState('watch-history', []);
|
|
|
|
const [unavailableUris] = React.useState([]);
|
2022-04-20 16:15:42 +02:00
|
|
|
|
2022-04-26 16:59:40 +02:00
|
|
|
function clearHistory() {
|
|
|
|
setHistory([]);
|
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-02 08:32:33 +02:00
|
|
|
<Icon icon={ICONS.WATCHHISTORY} style={{ marginRight: 'var(--spacing-s)' }} />
|
2022-04-26 16:59:40 +02:00
|
|
|
{__('Watch History')}
|
|
|
|
</h1>
|
|
|
|
|
|
|
|
<div className="claim-list__alt-controls--wrap">
|
|
|
|
{history.length > 0 && (
|
|
|
|
<Button
|
|
|
|
title={__('Clear History')}
|
|
|
|
button="primary"
|
|
|
|
label={__('Clear History')}
|
|
|
|
onClick={() => clearHistory()}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
2022-04-20 16:15:42 +02:00
|
|
|
</div>
|
2022-04-26 16:59:40 +02:00
|
|
|
{history.length > 0 && (
|
|
|
|
<ClaimList uris={history} collectionId={collectionId} unavailableUris={unavailableUris} inHistory />
|
|
|
|
)}
|
2022-05-02 10:43:27 +02:00
|
|
|
{history.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>
|
|
|
|
);
|
2022-04-20 16:15:42 +02:00
|
|
|
}
|