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

59 lines
1.7 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';
type Props = {
allDownloadedUrlsCount: number,
myPurchases: Array<string>,
fetchingMyPurchases: boolean,
fetchingFileList: boolean,
2020-05-21 17:38:28 +02:00
doPurchaseList: 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(() => {
doPurchaseList(page);
}, [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
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")
}
subtitle={
<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;