lbry-desktop/ui/page/fileListDownloaded/index.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import {
makeSelectSearchDownloadUrlsForPage,
selectDownloadUrlsCount,
selectIsFetchingFileList,
} from 'redux/selectors/file_info';
import {
makeSelectMyPurchasesForPage,
selectIsFetchingMyPurchases,
selectMyPurchasesCount,
} from 'redux/selectors/claims';
import FileListDownloaded from './view';
2019-09-23 19:32:38 +02:00
import { withRouter } from 'react-router';
2019-09-23 19:32:38 +02:00
const select = (state, props) => {
const { history, location } = props;
const { search } = location;
2019-09-23 19:32:38 +02:00
const urlParams = new URLSearchParams(search);
const query = urlParams.get('query') || '';
2019-09-25 23:17:23 +02:00
const page = Number(urlParams.get('page')) || 1;
2019-09-23 19:32:38 +02:00
return {
page,
history,
query,
downloadedUrlsCount: selectDownloadUrlsCount(state),
myPurchasesCount: selectMyPurchasesCount(state),
myPurchases: makeSelectMyPurchasesForPage(query, page)(state),
myDownloads: makeSelectSearchDownloadUrlsForPage(query, page)(state),
fetchingFileList: selectIsFetchingFileList(state),
fetchingMyPurchases: selectIsFetchingMyPurchases(state),
2019-09-23 19:32:38 +02:00
};
};
2020-05-21 17:38:28 +02:00
export default withRouter(connect(select)(FileListDownloaded));