2018-06-13 23:07:06 +02:00
|
|
|
// @flow
|
2019-10-03 23:20:55 +02:00
|
|
|
import React, { useState } from 'react';
|
2018-03-26 23:32:43 +02:00
|
|
|
import Button from 'component/button';
|
2019-06-19 07:05:43 +02:00
|
|
|
import ClaimList from 'component/claimList';
|
2019-09-23 19:32:38 +02:00
|
|
|
import Paginate from 'component/common/paginate';
|
|
|
|
import { PAGE_SIZE } from 'constants/claim';
|
2019-10-03 23:20:55 +02:00
|
|
|
import { Form } from 'component/common/form-components/form';
|
|
|
|
import Icon from 'component/common/icon';
|
|
|
|
import * as ICONS from '../../constants/icons';
|
|
|
|
import { FormField } from '../../component/common/form-components/form-field';
|
|
|
|
import { withRouter } from 'react-router';
|
2017-04-23 18:10:45 +02:00
|
|
|
|
2018-06-13 23:07:06 +02:00
|
|
|
type Props = {
|
|
|
|
fetching: boolean,
|
2019-10-03 23:20:55 +02:00
|
|
|
allDownloadedUrlsCount: number,
|
2019-09-25 23:37:01 +02:00
|
|
|
downloadedUrls: Array<string>,
|
|
|
|
downloadedUrlsCount: ?number,
|
2019-09-23 19:32:38 +02:00
|
|
|
history: { replace: string => void },
|
|
|
|
page: number,
|
2019-10-27 15:41:43 +01:00
|
|
|
query: string,
|
2018-06-13 23:07:06 +02:00
|
|
|
};
|
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
function FileListDownloaded(props: Props) {
|
2019-10-03 23:20:55 +02:00
|
|
|
const { fetching, history, query, allDownloadedUrlsCount, downloadedUrls, downloadedUrlsCount } = props;
|
|
|
|
const hasDownloads = allDownloadedUrlsCount > 0;
|
|
|
|
|
|
|
|
const [searchQuery, setSearchQuery] = useState('');
|
|
|
|
|
|
|
|
function handleInputChange(e) {
|
|
|
|
const { value } = e.target;
|
|
|
|
if (value !== searchQuery) {
|
|
|
|
setSearchQuery(value);
|
|
|
|
history.replace(`?query=${value}&page=1`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-11 20:10:58 +02:00
|
|
|
return (
|
|
|
|
// Removed the <Page> wapper to try combining this page with UserHistory
|
|
|
|
// This should eventually move into /components if we want to keep it this way
|
|
|
|
<React.Fragment>
|
|
|
|
{hasDownloads ? (
|
|
|
|
<div className="card">
|
2019-06-28 09:33:07 +02:00
|
|
|
<ClaimList
|
2019-07-21 23:31:22 +02:00
|
|
|
header={__('Your Library')}
|
2019-10-03 23:20:55 +02:00
|
|
|
headerAltControls={
|
|
|
|
<Form onSubmit={() => {}} className="wunderbar--inline">
|
|
|
|
<Icon icon={ICONS.SEARCH} />
|
|
|
|
<FormField
|
|
|
|
className="wunderbar__input"
|
|
|
|
onChange={handleInputChange}
|
|
|
|
value={query}
|
|
|
|
type="text"
|
2019-10-27 15:41:43 +01:00
|
|
|
name="query"
|
2019-10-03 23:20:55 +02:00
|
|
|
placeholder={__('Search')}
|
|
|
|
/>
|
|
|
|
</Form>
|
|
|
|
}
|
2019-06-28 09:33:07 +02:00
|
|
|
persistedStorageKey="claim-list-downloaded"
|
2019-10-03 23:20:55 +02:00
|
|
|
empty={__('No results for %query%', { query })}
|
2019-09-25 23:37:01 +02:00
|
|
|
uris={downloadedUrls}
|
2019-06-28 09:33:07 +02:00
|
|
|
loading={fetching}
|
|
|
|
/>
|
2019-09-25 23:37:01 +02:00
|
|
|
<Paginate totalPages={Math.ceil(Number(downloadedUrlsCount) / Number(PAGE_SIZE))} loading={fetching} />
|
2019-06-11 20:10:58 +02:00
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className="main--empty">
|
|
|
|
<section className="card card--section">
|
2019-11-22 22:13:00 +01:00
|
|
|
<h2 className="card__title card__title--deprecated">
|
|
|
|
{__("You haven't downloaded anything from LBRY yet.")}
|
|
|
|
</h2>
|
2019-07-21 23:31:22 +02:00
|
|
|
<div className="card__actions card__actions--center">
|
|
|
|
<Button button="primary" navigate="/" label={__('Explore new content')} />
|
2019-06-11 20:10:58 +02:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</React.Fragment>
|
|
|
|
);
|
2017-04-23 18:10:45 +02:00
|
|
|
}
|
|
|
|
|
2019-10-03 23:20:55 +02:00
|
|
|
export default withRouter(FileListDownloaded);
|