check subscription by uri

This commit is contained in:
Travis Eden 2018-08-20 10:01:32 -04:00
parent 5e270c129c
commit 3ba8b7e08f

View file

@ -131,7 +131,9 @@ export const doCheckSubscription = (subscriptionUri: string, notify?: boolean) =
// no dispatching FETCH_CHANNEL_CLAIMS_STARTED; causes loading issues on <SubscriptionsPage> // no dispatching FETCH_CHANNEL_CLAIMS_STARTED; causes loading issues on <SubscriptionsPage>
const state = getState(); const state = getState();
const savedSubscription = state.subscriptions.subscriptions.find(sub => sub.uri === subscriptionUri); const savedSubscription = state.subscriptions.subscriptions.find(
sub => sub.uri === subscriptionUri
);
Lbry.claim_list_by_channel({ uri: subscriptionUri, page: 1 }).then(result => { Lbry.claim_list_by_channel({ uri: subscriptionUri, page: 1 }).then(result => {
const claimResult = result[subscriptionUri] || {}; const claimResult = result[subscriptionUri] || {};
@ -168,7 +170,6 @@ export const doCheckSubscription = (subscriptionUri: string, notify?: boolean) =
dispatch(doPurchaseUri(uri, { cost: 0 })); dispatch(doPurchaseUri(uri, { cost: 0 }));
} }
}); });
} }
// always setLatest; important for newly subscribed channels // always setLatest; important for newly subscribed channels
@ -270,7 +271,7 @@ export const doCheckSubscriptions = () => (dispatch: Dispatch, getState: () => a
const state = getState(); const state = getState();
const subscriptions = selectSubscriptions(state); const subscriptions = selectSubscriptions(state);
subscriptions.forEach((sub: Subscription) => { subscriptions.forEach((sub: Subscription) => {
dispatch(doCheckSubscription(sub, true)); dispatch(doCheckSubscription(sub.uri, true));
}); });
}; };
@ -282,7 +283,7 @@ export const doCheckSubscriptionsInit = () => (dispatch: Dispatch) => {
setTimeout(() => dispatch(doCheckSubscriptions()), 10000); setTimeout(() => dispatch(doCheckSubscriptions()), 10000);
const checkSubscriptionsTimer = setInterval( const checkSubscriptionsTimer = setInterval(
() => dispatch(doCheckSubscriptions()), () => dispatch(doCheckSubscriptions()),
20000//CHECK_SUBSCRIPTIONS_INTERVAL 20000 //CHECK_SUBSCRIPTIONS_INTERVAL
); );
dispatch({ dispatch({
type: ACTIONS.CHECK_SUBSCRIPTIONS_SUBSCRIBE, type: ACTIONS.CHECK_SUBSCRIPTIONS_SUBSCRIBE,