fix: sub autodownloads

This commit is contained in:
Thomas Zarebczan 2019-08-30 15:11:04 -04:00 committed by Sean Yesmunt
parent 886814b900
commit 93e3de8c21

View file

@ -202,7 +202,13 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
if (!savedSubscription) { if (!savedSubscription) {
throw Error(`Trying to find new content for ${subscriptionUri} but it doesn't exist in your subscriptions`); throw Error(`Trying to find new content for ${subscriptionUri} but it doesn't exist in your subscriptions`);
} }
dispatch({
type: ACTIONS.FETCH_CHANNEL_CLAIMS_STARTED,
data: {
uri: subscriptionUri,
page: 1,
},
});
// We may be duplicating calls here. Can this logic be baked into doFetchClaimsByChannel? // We may be duplicating calls here. Can this logic be baked into doFetchClaimsByChannel?
Lbry.claim_search({ Lbry.claim_search({
channel: subscriptionUri, channel: subscriptionUri,
@ -218,6 +224,15 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
return; return;
} }
dispatch({
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
data: {
uri: subscriptionUri,
claims: claimsInChannel || [],
page: 1,
},
});
// Determine if the latest subscription currently saved is actually the latest subscription // Determine if the latest subscription currently saved is actually the latest subscription
const latestIndex = claimsInChannel.findIndex(claim => claim.permanent_url === savedSubscription.latest); const latestIndex = claimsInChannel.findIndex(claim => claim.permanent_url === savedSubscription.latest);
@ -231,7 +246,7 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
const newUnread = []; const newUnread = [];
claimsInChannel.slice(0, latestIndexToNotify).forEach(claim => { claimsInChannel.slice(0, latestIndexToNotify).forEach(claim => {
const uri = claim.permanent_url; const uri = claim.canonical_url;
const shouldDownload = const shouldDownload =
shouldAutoDownload && Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.fee); shouldAutoDownload && Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.fee);
@ -271,14 +286,6 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
// calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED // calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED
// means it will delete a non-existant fetchingChannelClaims[uri] // means it will delete a non-existant fetchingChannelClaims[uri]
dispatch({
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
data: {
uri: subscriptionUri,
claims: claimsInChannel || [],
page: 1,
},
});
}); });
}; };