add makeSelectFilePartlyDownloaded selector

This commit is contained in:
Sean Yesmunt 2019-08-14 12:52:24 -04:00
parent 4e093983ea
commit b3692b532f
3 changed files with 36 additions and 4 deletions

13
dist/bundle.es.js vendored
View file

@ -2615,6 +2615,18 @@ const makeSelectUriIsStreamable = uri => reselect.createSelector(makeSelectMedia
const makeSelectDownloadPathForUri = uri => reselect.createSelector(makeSelectFileInfoForUri(uri), fileInfo => { const makeSelectDownloadPathForUri = uri => reselect.createSelector(makeSelectFileInfoForUri(uri), fileInfo => {
return fileInfo && fileInfo.download_path; return fileInfo && fileInfo.download_path;
}); });
const makeSelectFilePartlyDownloaded = uri => reselect.createSelector(selectFileInfosByOutpoint, makeSelectClaimForUri(uri), (downloadsByOutpoint, claim) => {
if (!claim) {
return false;
}
const { txid, nout } = claim;
const outpoint = `${txid}:${nout}`;
const isDownloaded = downloadsByOutpoint[outpoint];
return isDownloaded;
});
const makeSelectFileNameForUri = uri => reselect.createSelector(makeSelectFileInfoForUri(uri), fileInfo => { const makeSelectFileNameForUri = uri => reselect.createSelector(makeSelectFileInfoForUri(uri), fileInfo => {
return fileInfo && fileInfo.file_name; return fileInfo && fileInfo.file_name;
}); });
@ -4866,6 +4878,7 @@ exports.makeSelectDownloadingForUri = makeSelectDownloadingForUri;
exports.makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims; exports.makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims;
exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri; exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri;
exports.makeSelectFileNameForUri = makeSelectFileNameForUri; exports.makeSelectFileNameForUri = makeSelectFileNameForUri;
exports.makeSelectFilePartlyDownloaded = makeSelectFilePartlyDownloaded;
exports.makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileForUri; exports.makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileForUri;
exports.makeSelectIsUriResolving = makeSelectIsUriResolving; exports.makeSelectIsUriResolving = makeSelectIsUriResolving;
exports.makeSelectLoadingForUri = makeSelectLoadingForUri; exports.makeSelectLoadingForUri = makeSelectLoadingForUri;

View file

@ -221,6 +221,7 @@ export {
makeSelectUriIsStreamable, makeSelectUriIsStreamable,
makeSelectDownloadPathForUri, makeSelectDownloadPathForUri,
makeSelectFileNameForUri, makeSelectFileNameForUri,
makeSelectFilePartlyDownloaded,
} from 'redux/selectors/file_info'; } from 'redux/selectors/file_info';
export { export {

View file

@ -4,6 +4,7 @@ import {
selectMyClaims, selectMyClaims,
selectClaimsById, selectClaimsById,
makeSelectContentTypeForUri, makeSelectContentTypeForUri,
makeSelectClaimForUri,
} from 'redux/selectors/claims'; } from 'redux/selectors/claims';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { buildURI } from 'lbryURI'; import { buildURI } from 'lbryURI';
@ -241,7 +242,7 @@ export const selectDownloadedUris = createSelector(
.map(claim => `lbry://${claim.claim_name}#${claim.claim_id}`) .map(claim => `lbry://${claim.claim_name}#${claim.claim_id}`)
); );
export const makeSelectMediaTypeForUri = (uri: string) => export const makeSelectMediaTypeForUri = uri =>
createSelector( createSelector(
makeSelectFileInfoForUri(uri), makeSelectFileInfoForUri(uri),
makeSelectContentTypeForUri(uri), makeSelectContentTypeForUri(uri),
@ -255,7 +256,7 @@ export const makeSelectMediaTypeForUri = (uri: string) =>
} }
); );
export const makeSelectUriIsStreamable = (uri: string) => export const makeSelectUriIsStreamable = uri =>
createSelector( createSelector(
makeSelectMediaTypeForUri(uri), makeSelectMediaTypeForUri(uri),
mediaType => { mediaType => {
@ -264,14 +265,31 @@ export const makeSelectUriIsStreamable = (uri: string) =>
} }
); );
export const makeSelectDownloadPathForUri = (uri: string) => export const makeSelectDownloadPathForUri = uri =>
createSelector( createSelector(
makeSelectFileInfoForUri(uri), makeSelectFileInfoForUri(uri),
fileInfo => { fileInfo => {
return fileInfo && fileInfo.download_path; return fileInfo && fileInfo.download_path;
} }
); );
export const makeSelectFileNameForUri = (uri: string) =>
export const makeSelectFilePartlyDownloaded = uri =>
createSelector(
selectFileInfosByOutpoint,
makeSelectClaimForUri(uri),
(downloadsByOutpoint, claim) => {
if (!claim) {
return false;
}
const { txid, nout } = claim;
const outpoint = `${txid}:${nout}`;
const isDownloaded = downloadsByOutpoint[outpoint];
return isDownloaded;
}
);
export const makeSelectFileNameForUri = uri =>
createSelector( createSelector(
makeSelectFileInfoForUri(uri), makeSelectFileInfoForUri(uri),
fileInfo => { fileInfo => {