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

62 lines
1.9 KiB
React
Raw Normal View History

2019-06-28 09:33:07 +02:00
// @flow
import React from 'react';
import Button from 'component/button';
2019-06-28 09:33:07 +02:00
import Page from 'component/page';
import Spinner from 'component/spinner';
2019-06-28 09:33:07 +02:00
import DownloadList from 'page/fileListDownloaded';
import Yrbl from 'component/yrbl';
2020-05-21 17:38:28 +02:00
import { useHistory } from 'react-router';
2020-05-21 19:23:52 +02:00
// https://github.com/lbryio/lbry-sdk/issues/2964
2020-05-21 19:18:55 +02:00
export const PURCHASES_PAGE_SIZE = 10;
type Props = {
allDownloadedUrlsCount: number,
myPurchases: Array<string>,
fetchingMyPurchases: boolean,
fetchingFileList: boolean,
2020-05-21 19:18:55 +02:00
doPurchaseList: (number, number) => void,
};
function LibraryPage(props: Props) {
2020-05-21 17:38:28 +02:00
const { allDownloadedUrlsCount, myPurchases, fetchingMyPurchases, fetchingFileList, doPurchaseList } = props;
const { location } = useHistory();
const urlParams = new URLSearchParams(location.search);
const page = Number(urlParams.get('page')) || 1;
const hasDownloads = allDownloadedUrlsCount > 0 || (myPurchases && myPurchases.length > 0);
const loading = fetchingFileList || fetchingMyPurchases;
2019-06-28 09:33:07 +02:00
2020-05-21 17:38:28 +02:00
React.useEffect(() => {
2020-05-21 19:18:55 +02:00
doPurchaseList(page, PURCHASES_PAGE_SIZE);
2020-05-21 17:38:28 +02:00
}, [doPurchaseList, page]);
2019-06-28 09:33:07 +02:00
return (
<Page noFooter noSideNavigation settingsPage backout={{ title: __('Purchases'), backLabel: __('Back') }}>
{loading && !hasDownloads && (
<div className="main--empty">
<Spinner delayed />
</div>
)}
{!loading && !hasDownloads && (
<div className="main--empty">
<Yrbl
2020-05-21 17:38:28 +02:00
title={
IS_WEB ? __("You haven't purchased anything yet") : __("You haven't downloaded anything from LBRY yet")
}
2020-09-02 22:08:37 +02:00
actions={
<div className="section__actions">
2020-05-21 17:38:28 +02:00
<Button button="primary" navigate="/" label={__('Explore New Content')} />
</div>
}
/>
</div>
)}
{hasDownloads && <DownloadList />}
2019-06-28 09:33:07 +02:00
</Page>
);
}
export default LibraryPage;