Reduce unnecessary api calls

This commit is contained in:
liamcardenas 2018-03-07 12:02:53 -08:00
parent 3f8f25dc43
commit 174285aea8
2 changed files with 21 additions and 13 deletions

View file

@ -14,6 +14,7 @@ import { makeSelectCostInfoForUri } from 'redux/selectors/cost_info';
import { selectShowNsfw } from 'redux/selectors/settings'; import { selectShowNsfw } from 'redux/selectors/settings';
import FilePage from './view'; import FilePage from './view';
import { makeSelectCurrentParam } from 'redux/selectors/navigation'; import { makeSelectCurrentParam } from 'redux/selectors/navigation';
import { selectSubscriptions } from 'redux/selectors/subscriptions';
const select = (state, props) => ({ const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state), claim: makeSelectClaimForUri(props.uri)(state),
@ -24,6 +25,7 @@ const select = (state, props) => ({
tab: makeSelectCurrentParam('tab')(state), tab: makeSelectCurrentParam('tab')(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state), fileInfo: makeSelectFileInfoForUri(props.uri)(state),
rewardedContentClaimIds: selectRewardContentClaimIds(state, props), rewardedContentClaimIds: selectRewardContentClaimIds(state, props),
subscriptions: selectSubscriptions(state),
}); });
const perform = dispatch => ({ const perform = dispatch => ({

View file

@ -37,19 +37,25 @@ class FilePage extends React.PureComponent {
} }
checkSubscriptionLatest(props) { checkSubscriptionLatest(props) {
props.checkSubscriptionLatest( if (
{ props.subscriptions
channelName: props.claim.channel_name, .map(subscription => subscription.channelName)
uri: buildURI( .indexOf(props.claim.channel_name) !== -1
{ ) {
contentName: props.claim.channel_name, props.checkSubscriptionLatest(
claimId: props.claim.value.publisherSignature.certificateId, {
}, channelName: props.claim.channel_name,
false uri: buildURI(
), {
}, contentName: props.claim.channel_name,
buildURI({ contentName: props.claim.name, claimId: props.claim.claim_id }, false) claimId: props.claim.value.publisherSignature.certificateId,
); },
false
),
},
buildURI({ contentName: props.claim.name, claimId: props.claim.claim_id }, false)
);
}
} }
render() { render() {