simplify logic inside of subscription react component
This commit is contained in:
parent
38de5edc90
commit
9b9ac580ee
3 changed files with 8 additions and 15 deletions
|
@ -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}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
|
|
@ -64,7 +64,7 @@ export const selectHeaderLinks = createSelector(selectCurrentPage, page => {
|
|||
case "discover":
|
||||
case "subscriptions":
|
||||
return {
|
||||
discover: __("Home"),
|
||||
discover: __("Discover"),
|
||||
subscriptions: __("Subscriptions"),
|
||||
};
|
||||
default:
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue