Rc fixes #2075
3 changed files with 69 additions and 70 deletions
|
@ -205,7 +205,7 @@ export const doRemoveUnreadSubscription = (channelUri: string, readUri: string)
|
||||||
dispatch(doRemoveUnreadSubscriptions(channelUri, [readUri]));
|
dispatch(doRemoveUnreadSubscriptions(channelUri, [readUri]));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: boolean) => async (
|
export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: boolean) => (
|
||||||
dispatch: ReduxDispatch,
|
dispatch: ReduxDispatch,
|
||||||
getState: GetState
|
getState: GetState
|
||||||
) => {
|
) => {
|
||||||
|
@ -223,85 +223,86 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const claimListByChannel = await Lbry.claim_list_by_channel({ uri: subscriptionUri, page: 1 });
|
Lbry.claim_list_by_channel({ uri: subscriptionUri, page: 1 }).then(claimListByChannel => {
|
||||||
const claimResult = claimListByChannel[subscriptionUri] || {};
|
const claimResult = claimListByChannel[subscriptionUri] || {};
|
||||||
const { claims_in_channel: claimsInChannel } = claimResult;
|
const { claims_in_channel: claimsInChannel } = claimResult;
|
||||||
|
|
||||||
// may happen if subscribed to an abandoned channel or an empty channel
|
// may happen if subscribed to an abandoned channel or an empty channel
|
||||||
if (!claimsInChannel || !claimsInChannel.length) {
|
if (!claimsInChannel || !claimsInChannel.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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(
|
const latestIndex = claimsInChannel.findIndex(
|
||||||
claim => `${claim.name}#${claim.claim_id}` === savedSubscription.latest
|
claim => `${claim.name}#${claim.claim_id}` === savedSubscription.latest
|
||||||
);
|
);
|
||||||
|
|||||||
|
|
||||||
// If latest is -1, it is a newly subscribed channel or there have been 10+ claims published since last viewed
|
// If latest is -1, it is a newly subscribed channel or there have been 10+ claims published since last viewed
|
||||||
const latestIndexToNotify = latestIndex === -1 ? 10 : latestIndex;
|
const latestIndexToNotify = latestIndex === -1 ? 10 : latestIndex;
|
||||||
|
|
||||||
// If latest is 0, nothing has changed
|
// If latest is 0, nothing has changed
|
||||||
// Do not download/notify about new content, it would download/notify 10 claims per channel
|
// Do not download/notify about new content, it would download/notify 10 claims per channel
|
||||||
if (latestIndex !== 0 && savedSubscription.latest) {
|
if (latestIndex !== 0 && savedSubscription.latest) {
|
||||||
let downloadCount = 0;
|
let downloadCount = 0;
|
||||||
|
|
||||||
const newUnread = [];
|
const newUnread = [];
|
||||||
claimsInChannel.slice(0, latestIndexToNotify).forEach(claim => {
|
claimsInChannel.slice(0, latestIndexToNotify).forEach(claim => {
|
||||||
const uri = buildURI({ contentName: claim.name, claimId: claim.claim_id }, true);
|
const uri = buildURI({ contentName: claim.name, claimId: claim.claim_id }, true);
|
||||||
const shouldDownload =
|
const shouldDownload =
|
||||||
shouldAutoDownload &&
|
shouldAutoDownload &&
|
||||||
Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.stream.metadata.fee);
|
Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.stream.metadata.fee);
|
||||||
|
|
||||||
// Add the new content to the list of "un-read" subscriptions
|
// Add the new content to the list of "un-read" subscriptions
|
||||||
if (shouldNotify) {
|
if (shouldNotify) {
|
||||||
newUnread.push(uri);
|
newUnread.push(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldDownload) {
|
if (shouldDownload) {
|
||||||
downloadCount += 1;
|
downloadCount += 1;
|
||||||
dispatch(doPurchaseUri(uri, { cost: 0 }, true));
|
dispatch(doPurchaseUri(uri, { cost: 0 }, true));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dispatch(
|
||||||
|
doUpdateUnreadSubscriptions(
|
||||||
|
subscriptionUri,
|
||||||
|
newUnread,
|
||||||
|
downloadCount > 0 ? NOTIFICATION_TYPES.DOWNLOADING : NOTIFICATION_TYPES.NOTIFY_ONLY
|
||||||
|
)
|
||||||
|
);
|
||||||
parens parens
|
|||||||
|
}
|
||||||
|
|
||||||
|
// Set the latest piece of content for a channel
|
||||||
|
// This allows the app to know if there has been new content since it was last set
|
||||||
dispatch(
|
dispatch(
|
||||||
doUpdateUnreadSubscriptions(
|
setSubscriptionLatest(
|
||||||
subscriptionUri,
|
{
|
||||||
newUnread,
|
channelName: claimsInChannel[0].channel_name,
|
||||||
downloadCount > 0 ? NOTIFICATION_TYPES.DOWNLOADING : NOTIFICATION_TYPES.NOTIFY_ONLY
|
uri: buildURI(
|
||||||
|
{
|
||||||
|
channelName: claimsInChannel[0].channel_name,
|
||||||
|
claimId: claimsInChannel[0].claim_id,
|
||||||
|
},
|
||||||
|
false
|
||||||
|
),
|
||||||
|
},
|
||||||
|
buildURI(
|
||||||
|
{ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id },
|
||||||
|
false
|
||||||
Can you put parens for better legibility? Can you put parens for better legibility?
|
|||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// Set the latest piece of content for a channel
|
// calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED
|
||||||
// This allows the app to know if there has been new content since it was last set
|
// means it will delete a non-existant fetchingChannelClaims[uri]
|
||||||
dispatch(
|
dispatch({
|
||||||
setSubscriptionLatest(
|
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
|
||||||
{
|
data: {
|
||||||
channelName: claimsInChannel[0].channel_name,
|
uri: subscriptionUri,
|
||||||
uri: buildURI(
|
claims: claimsInChannel || [],
|
||||||
{
|
page: 1,
|
||||||
channelName: claimsInChannel[0].channel_name,
|
|
||||||
claimId: claimsInChannel[0].claim_id,
|
|
||||||
},
|
|
||||||
false
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
buildURI(
|
});
|
||||||
{ contentName: claimsInChannel[0].name, claimId: claimsInChannel[0].claim_id },
|
|
||||||
false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED
|
|
||||||
// means it will delete a non-existant fetchingChannelClaims[uri]
|
|
||||||
dispatch({
|
|
||||||
type: ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED,
|
|
||||||
data: {
|
|
||||||
uri: subscriptionUri,
|
|
||||||
claims: claimsInChannel || [],
|
|
||||||
page: 1,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -227,8 +227,7 @@
|
||||||
|
|
||||||
.card__subtitle {
|
.card__subtitle {
|
||||||
color: $lbry-gray-5;
|
color: $lbry-gray-5;
|
||||||
font-size: .9em;
|
font-size: 0.9em;
|
||||||
line-height: .9em;
|
|
||||||
padding-top: $spacing-vertical * 1/3;
|
padding-top: $spacing-vertical * 1/3;
|
||||||
|
|
||||||
@media (min-width: $large-breakpoint) {
|
@media (min-width: $large-breakpoint) {
|
||||||
|
|
|
@ -13,7 +13,6 @@ const isDev = PROCESS_ARGV && PROCESS_ARGV.original &&
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// This rule is temporarily necessary until https://github.com/electron-userland/electron-webpack/issues/60 is fixed.
|
// This rule is temporarily necessary until https://github.com/electron-userland/electron-webpack/issues/60 is fixed.
|
||||||
entry: ['babel-polyfill', `${ELECTRON_RENDERER_PROCESS_ROOT}/index.js`],
|
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue
no more
await
😞