selectors for library and download pagination

This commit is contained in:
jessop 2019-09-23 13:00:12 -04:00
parent fe4ae1568e
commit 2cdc43b271
4 changed files with 60 additions and 2 deletions

21
dist/bundle.es.js vendored
View file

@ -1494,7 +1494,6 @@ function concatClaims(claimList = [], concatClaimList = []) {
}
//
const selectState$2 = state => state.claims || {};
const selectClaimsById = reselect.createSelector(selectState$2, state => state.byId || {});
@ -1843,6 +1842,14 @@ const selectUpdatingChannel = reselect.createSelector(selectState$2, state => st
const selectUpdateChannelError = reselect.createSelector(selectState$2, state => state.updateChannelError);
const makeSelectMyStreamUrisForPage = (page = 0) => reselect.createSelector(selectMyClaimUrisWithoutChannels, uris => {
const start = Number(page) * Number(PAGE_SIZE);
const end = (Number(page) + 1) * Number(PAGE_SIZE);
return uris && uris.length ? uris.slice(start, end) : [];
});
const selectMyStreamUrisCount = reselect.createSelector(selectMyClaimUrisWithoutChannels, channels => channels.length);
function formatCredits(amount, precision, shortFormat = false) {
let actualAmount = parseFloat(amount),
suffix = '';
@ -2707,6 +2714,14 @@ const makeSelectFileNameForUri = uri => reselect.createSelector(makeSelectFileIn
return fileInfo && fileInfo.file_name;
});
const makeSelectDownloadUrisForPage = (page = 0) => reselect.createSelector(selectDownloadedUris, uris => {
const start = Number(page) * Number(PAGE_SIZE);
const end = (Number(page) + 1) * Number(PAGE_SIZE);
return uris && uris.length ? uris.slice(start, end) : [];
});
const selectDownloadUrisCount = reselect.createSelector(selectDownloadedUris, uris => uris.length);
//
const selectState$4 = state => state.file || {};
@ -5059,6 +5074,7 @@ exports.makeSelectContentTypeForUri = makeSelectContentTypeForUri;
exports.makeSelectCoverForUri = makeSelectCoverForUri;
exports.makeSelectDateForUri = makeSelectDateForUri;
exports.makeSelectDownloadPathForUri = makeSelectDownloadPathForUri;
exports.makeSelectDownloadUrisForPage = makeSelectDownloadUrisForPage;
exports.makeSelectDownloadingForUri = makeSelectDownloadingForUri;
exports.makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims;
exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri;
@ -5071,6 +5087,7 @@ exports.makeSelectLoadingForUri = makeSelectLoadingForUri;
exports.makeSelectMediaTypeForUri = makeSelectMediaTypeForUri;
exports.makeSelectMetadataForUri = makeSelectMetadataForUri;
exports.makeSelectMetadataItemForUri = makeSelectMetadataItemForUri;
exports.makeSelectMyStreamUrisForPage = makeSelectMyStreamUrisForPage;
exports.makeSelectNsfwCountForChannel = makeSelectNsfwCountForChannel;
exports.makeSelectNsfwCountFromUris = makeSelectNsfwCountFromUris;
exports.makeSelectPendingByUri = makeSelectPendingByUri;
@ -5116,6 +5133,7 @@ exports.selectClaimsByUri = selectClaimsByUri;
exports.selectCreateChannelError = selectCreateChannelError;
exports.selectCreatingChannel = selectCreatingChannel;
exports.selectCurrentChannelPage = selectCurrentChannelPage;
exports.selectDownloadUrisCount = selectDownloadUrisCount;
exports.selectDownloadedUris = selectDownloadedUris;
exports.selectDownloadingByOutpoint = selectDownloadingByOutpoint;
exports.selectDownloadingFileInfos = selectDownloadingFileInfos;
@ -5152,6 +5170,7 @@ exports.selectMyClaims = selectMyClaims;
exports.selectMyClaimsOutpoints = selectMyClaimsOutpoints;
exports.selectMyClaimsRaw = selectMyClaimsRaw;
exports.selectMyClaimsWithoutChannels = selectMyClaimsWithoutChannels;
exports.selectMyStreamUrisCount = selectMyStreamUrisCount;
exports.selectPendingById = selectPendingById;
exports.selectPendingClaims = selectPendingClaims;
exports.selectPlayingUri = selectPlayingUri;

View file

@ -206,6 +206,8 @@ export {
selectCreatingChannel,
selectCreateChannelError,
selectChannelImportPending,
makeSelectMyStreamUrisForPage,
selectMyStreamUrisCount,
} from 'redux/selectors/claims';
export { makeSelectCommentsForUri } from 'redux/selectors/comments';
@ -230,6 +232,8 @@ export {
makeSelectDownloadPathForUri,
makeSelectFileNameForUri,
makeSelectFilePartlyDownloaded,
makeSelectDownloadUrisForPage,
selectDownloadUrisCount,
} from 'redux/selectors/file_info';
export {

View file

@ -5,7 +5,7 @@ import { selectSupportsByOutpoint } from 'redux/selectors/wallet';
import { createSelector } from 'reselect';
import { isClaimNsfw, createNormalizedClaimSearchKey } from 'util/claim';
import { getSearchQueryString } from 'util/query-params';
import { PAGE_SIZE } from 'constants/claim';
const selectState = state => state.claims || {};
export const selectClaimsById = createSelector(
@ -591,3 +591,20 @@ export const selectUpdateChannelError = createSelector(
selectState,
state => state.updateChannelError
);
export const makeSelectMyStreamUrisForPage = (page: number = 0) =>
createSelector(
selectMyClaimUrisWithoutChannels,
uris => {
const start = (Number(page) * Number(PAGE_SIZE));
const end = ((Number(page) + 1) * Number(PAGE_SIZE));
return (uris && uris.length)
? uris.slice(start, end)
: [];
}
);
export const selectMyStreamUrisCount = createSelector(
selectMyClaimUrisWithoutChannels,
channels => channels.length
);

View file

@ -9,6 +9,7 @@ import {
import { createSelector } from 'reselect';
import { buildURI } from 'lbryURI';
import Lbry from 'lbry';
import { PAGE_SIZE } from 'constants/claim';
export const selectState = state => state.fileInfo || {};
@ -202,3 +203,20 @@ export const makeSelectFileNameForUri = uri =>
return fileInfo && fileInfo.file_name;
}
);
export const makeSelectDownloadUrisForPage = (page = 0) =>
createSelector(
selectDownloadedUris,
uris => {
const start = (Number(page) * Number(PAGE_SIZE));
const end = ((Number(page) + 1) * Number(PAGE_SIZE));
return (uris && uris.length)
? uris.slice(start, end)
: [];
}
);
export const selectDownloadUrisCount = createSelector(
selectDownloadedUris,
uris => uris.length
);