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

60 lines
1.7 KiB
React
Raw Permalink 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>
{loading && !hasDownloads && (
<div className="main--empty">
<Spinner delayed />
</div>
)}
{!loading && !hasDownloads && (
<div className="main--empty">
<Yrbl
2022-01-07 20:02:33 +01:00
title={__("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;