simplify logic inside of subscription react component

This commit is contained in:
Sean Yesmunt 2017-12-08 16:07:12 -05:00
parent 38de5edc90
commit 9b9ac580ee
3 changed files with 8 additions and 15 deletions

View file

@ -56,14 +56,7 @@ export default class extends React.PureComponent<Props> {
render() {
const { subscriptions, savedSubscriptions } = this.props;
let someClaimsNotLoaded;
for (var i = 0; i < subscriptions.length; i++) {
const subscription = subscriptions[i];
if (!subscription.claims.length) {
someClaimsNotLoaded = true;
break;
}
}
const someClaimsNotLoaded = Boolean(subscriptions.find(subscription => !subscription.claims.length))
const fetchingSubscriptions =
!!savedSubscriptions.length &&
@ -92,17 +85,12 @@ export default class extends React.PureComponent<Props> {
return "";
}
// creating uris for each subscription file
const names = subscription.claims.slice().map(claim => {
return `${claim.name}#${claim.claim_id}`;
});
return (
<FeaturedCategory
key={subscription.channelName}
categoryLink={`lbry://${subscription.uri}`}
category={subscription.channelName}
names={names}
names={subscription.claims}
/>
);
})}

View file

@ -64,7 +64,7 @@ export const selectHeaderLinks = createSelector(selectCurrentPage, page => {
case "discover":
case "subscriptions":
return {
discover: __("Home"),
discover: __("Discover"),
subscriptions: __("Subscriptions"),
};
default:

View file

@ -39,6 +39,11 @@ export const selectSubscriptionsFromClaims = createSelector(
});
}
// all we really need is a uri for each claim
channelClaims = channelClaims.map(claim => {
return `${claim.name}#${claim.claim_id}`;
})
fetchedSubscriptions.push({
claims: channelClaims,
channelName: subscription.channelName,