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() {
|
render() {
|
||||||
const { subscriptions, savedSubscriptions } = this.props;
|
const { subscriptions, savedSubscriptions } = this.props;
|
||||||
|
|
||||||
let someClaimsNotLoaded;
|
const someClaimsNotLoaded = Boolean(subscriptions.find(subscription => !subscription.claims.length))
|
||||||
for (var i = 0; i < subscriptions.length; i++) {
|
|
||||||
const subscription = subscriptions[i];
|
|
||||||
if (!subscription.claims.length) {
|
|
||||||
someClaimsNotLoaded = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchingSubscriptions =
|
const fetchingSubscriptions =
|
||||||
!!savedSubscriptions.length &&
|
!!savedSubscriptions.length &&
|
||||||
|
@ -92,17 +85,12 @@ export default class extends React.PureComponent<Props> {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// creating uris for each subscription file
|
|
||||||
const names = subscription.claims.slice().map(claim => {
|
|
||||||
return `${claim.name}#${claim.claim_id}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FeaturedCategory
|
<FeaturedCategory
|
||||||
key={subscription.channelName}
|
key={subscription.channelName}
|
||||||
categoryLink={`lbry://${subscription.uri}`}
|
categoryLink={`lbry://${subscription.uri}`}
|
||||||
category={subscription.channelName}
|
category={subscription.channelName}
|
||||||
names={names}
|
names={subscription.claims}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -64,7 +64,7 @@ export const selectHeaderLinks = createSelector(selectCurrentPage, page => {
|
||||||
case "discover":
|
case "discover":
|
||||||
case "subscriptions":
|
case "subscriptions":
|
||||||
return {
|
return {
|
||||||
discover: __("Home"),
|
discover: __("Discover"),
|
||||||
subscriptions: __("Subscriptions"),
|
subscriptions: __("Subscriptions"),
|
||||||
};
|
};
|
||||||
default:
|
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({
|
fetchedSubscriptions.push({
|
||||||
claims: channelClaims,
|
claims: channelClaims,
|
||||||
channelName: subscription.channelName,
|
channelName: subscription.channelName,
|
||||||
|
|
Loading…
Reference in a new issue