Subscribe notify #1066
3 changed files with 33 additions and 6 deletions
|
@ -40,7 +40,13 @@ class FilePage extends React.PureComponent {
|
|||
props.checkSubscriptionLatest(
|
||||
{
|
||||
channelName: props.claim.channel_name,
|
||||
uri: buildURI({ contentName: props.claim.channel_name, claimId: props.claim.value.publisherSignature.certificateId }, false),
|
||||
uri: buildURI(
|
||||
{
|
||||
contentName: props.claim.channel_name,
|
||||
claimId: props.claim.value.publisherSignature.certificateId,
|
||||
},
|
||||
false
|
||||
),
|
||||
},
|
||||
buildURI({ contentName: props.claim.name, claimId: props.claim.claim_id }, false)
|
||||
);
|
||||
|
|
|
@ -365,7 +365,13 @@ export function doFetchClaimsByChannel(uri, page) {
|
|||
setSubscriptionLatest(
|
||||
{
|
||||
channelName: latest.channel_name,
|
||||
uri: buildURI({ contentName: latest.channel_name, claimId: latest.value.publisherSignature.certificateId }, false),
|
||||
uri: buildURI(
|
||||
{
|
||||
contentName: latest.channel_name,
|
||||
claimId: latest.value.publisherSignature.certificateId,
|
||||
},
|
||||
false
|
||||
),
|
||||
},
|
||||
buildURI({ contentName: latest.name, claimId: latest.claim_id }, false)
|
||||
)
|
||||
|
|
|
@ -51,7 +51,10 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di
|
|||
let count = subscription.latest
|
||||
? claimsInChannel.reduce(
|
||||
(prev, cur, index) =>
|
||||
buildURI({ contentName: cur.name, claimId: cur.claim_id}, false) === subscription.latest ? index : prev,
|
||||
buildURI({ contentName: cur.name, claimId: cur.claim_id }, false) ===
|
||||
subscription.latest
|
||||
? index
|
||||
: prev,
|
||||
-1
|
||||
)
|
||||
: 1;
|
||||
|
@ -59,7 +62,13 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di
|
|||
if (count !== 0) {
|
||||
if (!claimsInChannel[0].value.stream.metadata.fee) {
|
||||
dispatch(
|
||||
doPurchaseUri(buildURI({ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id }, false), { cost: 0 })
|
||||
doPurchaseUri(
|
||||
buildURI(
|
||||
{ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id },
|
||||
false
|
||||
),
|
||||
{ cost: 0 }
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -72,7 +81,10 @@ export const doCheckSubscription = (subscription: Subscription) => (dispatch: Di
|
|||
notif.onclick = () => {
|
||||
dispatch(
|
||||
doNavigate('/show', {
|
||||
uri: buildURI({ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id }, true),
|
||||
uri: buildURI(
|
||||
{ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id },
|
||||
true
|
||||
),
|
||||
})
|
||||
);
|
||||
};
|
||||
|
@ -96,7 +108,10 @@ export const checkSubscriptionLatest = (channel: Subscription, uri: string) => (
|
|||
if (
|
||||
claimsInChannel &&
|
||||
claimsInChannel.length &&
|
||||
buildURI({ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id }, false) === uri
|
||||
buildURI(
|
||||
{ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id },
|
||||
false
|
||||
) === uri
|
||||
) {
|
||||
dispatch(setSubscriptionLatest(channel, uri));
|
||||
check and set are different, set simply sets the value in the redux store. Check does an asynchronous call and sets the value accordingly by dispatching set, if that makes sense. check and set are different, set simply sets the value in the redux store. Check does an asynchronous call and sets the value accordingly by dispatching set, if that makes sense.
I'm asking two things in my question:
I'm asking two things in my question:
1) If we're already fetching the latest subscription data at time interval `n`, is it actually necessary to check for the latest for this same information when accessing a file page?
2) If it is necessary (for staleness reasons, presumably), why can't more of the code be shared between the two? Isn't `doCheckSubscription` a superset of the functionality provided by `checkSubscriptionLatest`? and why wouldn't you want `checkSubscriptionLatest` to also begin downloads? Furthermore, why do _both_ of these call `Lbry.claim_list_by_channel` when they could call `doFetchClaimsByChannel` instead?
@liamcardenas did you see above? @liamcardenas did you see above?
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue
Is this function actually necessary? Could
doCheckSubscription
just callsetSubscriptionLatest
?