fix: search downloads

This commit is contained in:
Sean Yesmunt 2018-04-02 23:41:23 -04:00
parent e21caa19f9
commit d56d3f31d5
4 changed files with 23 additions and 23 deletions

View file

@ -166,7 +166,7 @@ class FileList extends React.PureComponent<Props, State> {
const uri = buildURI(uriParams);
content.push(<FileCard key={claimName} uri={uri} showPrice={false} />);
content.push(<FileCard key={uri} uri={uri} showPrice={false} />);
});
return (

View file

@ -7,9 +7,7 @@ import debounce from 'util/debounce';
const SEARCH_DEBOUNCE_TIME = 800;
const NoResults = () => {
return <div className="file-tile">{__('No results')}</div>;
};
const NoResults = () => <div className="file-tile">{__('No results')}</div>;
type Props = {
search: string => void,

View file

@ -2,6 +2,7 @@ import {
selectClaimsByUri,
selectIsFetchingClaimListMine,
selectMyClaims,
selectClaimsById,
} from 'redux/selectors/claims';
import { createSelector } from 'reselect';
import { buildURI } from 'lbryURI';
@ -106,7 +107,7 @@ export const selectTotalDownloadProgress = createSelector(selectDownloadingFileI
});
export const selectSearchDownloadUris = query =>
createSelector(selectFileInfosDownloaded, fileInfos => {
createSelector(selectFileInfosDownloaded, selectClaimsById, (fileInfos, claimsById) => {
if (!query || !fileInfos.length) {
return null;
}
@ -129,19 +130,19 @@ export const selectSearchDownloadUris = query =>
const downloadResultsFromQuery = [];
fileInfos.forEach(fileInfo => {
const { channel_name, claim_name, metadata } = fileInfo;
const { channel_name: channelName, claim_name: claimName, metadata } = fileInfo;
const { author, description, title } = metadata;
if (channel_name) {
const channelName = channel_name.toLowerCase();
const strippedOutChannelName = channelName.slice(1); // trim off the @
if (searchQueryDictionary[channel_name] || searchQueryDictionary[strippedOutChannelName]) {
if (channelName) {
const lowerCaseChannel = channelName.toLowerCase();
const strippedOutChannelName = lowerCaseChannel.slice(1); // trim off the @
if (searchQueryDictionary[channelName] || searchQueryDictionary[strippedOutChannelName]) {
downloadResultsFromQuery.push(fileInfo);
return;
}
}
const nameParts = claim_name.toLowerCase().split('-');
const nameParts = claimName.toLowerCase().split('-');
if (arrayContainsQueryPart(nameParts)) {
downloadResultsFromQuery.push(fileInfo);
return;
@ -171,22 +172,23 @@ export const selectSearchDownloadUris = query =>
return downloadResultsFromQuery.length
? downloadResultsFromQuery.map(fileInfo => {
const {
channel_name: channelName,
claim_id: claimId,
claim_name: claimName,
value,
metadata,
} = fileInfo;
const { channel_name: channelName, claim_id: claimId, claim_name: claimName } = fileInfo;
const uriParams = {};
if (channelName) {
uriParams.channelName = channelName;
const claim = claimsById[claimId];
if (claim.value) {
uriParams.claimId = claim.value.publisherSignature.certificateId;
} else {
uriParams.claimId = claimId;
}
uriParams.claimId = claimId;
uriParams.claimId = claimId;
uriParams.channelName = channelName;
uriParams.contentName = claimName;
} else {
uriParams.claimId = claimId;
uriParams.claimName = claimName;
}
const uri = buildURI(uriParams);
return uri;

View file

@ -189,5 +189,5 @@ button:disabled {
opacity: 0.8;
border-radius: var(--btn-radius);
height: var(--btn-height);
padding: 0 3px;
padding: 10px;
}