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

View file

@ -37,6 +37,11 @@ class FilePage extends React.PureComponent {
}
checkSubscriptionLatest(props) {
if (
props.subscriptions
.map(subscription => subscription.channelName)
.indexOf(props.claim.channel_name) !== -1
) {
props.checkSubscriptionLatest(
{
channelName: props.claim.channel_name,
@ -51,6 +56,7 @@ class FilePage extends React.PureComponent {
buildURI({ contentName: props.claim.name, claimId: props.claim.claim_id }, false)
);
}
}
render() {
const {