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 => {
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 => {
return fileInfo && fileInfo.file_name;
});
@ -4866,6 +4878,7 @@ exports.makeSelectDownloadingForUri = makeSelectDownloadingForUri;
exports.makeSelectFetchingChannelClaims = makeSelectFetchingChannelClaims;
exports.makeSelectFileInfoForUri = makeSelectFileInfoForUri;
exports.makeSelectFileNameForUri = makeSelectFileNameForUri;
exports.makeSelectFilePartlyDownloaded = makeSelectFilePartlyDownloaded;
exports.makeSelectFirstRecommendedFileForUri = makeSelectFirstRecommendedFileForUri;
exports.makeSelectIsUriResolving = makeSelectIsUriResolving;
exports.makeSelectLoadingForUri = makeSelectLoadingForUri;

View file

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

View file

@ -4,6 +4,7 @@ import {
selectMyClaims,
selectClaimsById,
makeSelectContentTypeForUri,
makeSelectClaimForUri,
} from 'redux/selectors/claims';
import { createSelector } from 'reselect';
import { buildURI } from 'lbryURI';
@ -241,7 +242,7 @@ export const selectDownloadedUris = createSelector(
.map(claim => `lbry://${claim.claim_name}#${claim.claim_id}`)
);
export const makeSelectMediaTypeForUri = (uri: string) =>
export const makeSelectMediaTypeForUri = uri =>
createSelector(
makeSelectFileInfoForUri(uri),
makeSelectContentTypeForUri(uri),
@ -255,7 +256,7 @@ export const makeSelectMediaTypeForUri = (uri: string) =>
}
);
export const makeSelectUriIsStreamable = (uri: string) =>
export const makeSelectUriIsStreamable = uri =>
createSelector(
makeSelectMediaTypeForUri(uri),
mediaType => {
@ -264,14 +265,31 @@ export const makeSelectUriIsStreamable = (uri: string) =>
}
);
export const makeSelectDownloadPathForUri = (uri: string) =>
export const makeSelectDownloadPathForUri = uri =>
createSelector(
makeSelectFileInfoForUri(uri),
fileInfo => {
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(
makeSelectFileInfoForUri(uri),
fileInfo => {