fix: canonical url stuff
This commit is contained in:
parent
396e8fff4f
commit
35ca4fbc3d
3 changed files with 53 additions and 101 deletions
51
dist/bundle.es.js
vendored
51
dist/bundle.es.js
vendored
|
@ -1566,21 +1566,21 @@ const doCheckSubscription = (subscriptionUri, shouldNotify) => (dispatch, getSta
|
|||
|
||||
lbryRedux.Lbry.claim_search({
|
||||
channel: subscriptionUri,
|
||||
page: 1,
|
||||
page_size: PAGE_SIZE,
|
||||
valid_channel_signature: true,
|
||||
order_by: ['release_time']
|
||||
}).then(result => {
|
||||
order_by: ['release_time'],
|
||||
page: 1,
|
||||
page_size: PAGE_SIZE
|
||||
}).then(claimListByChannel => {
|
||||
const {
|
||||
items: claimsInChannel
|
||||
} = result; // may happen if subscribed to an abandoned channel or an empty channel
|
||||
} = claimListByChannel; // may happen if subscribed to an abandoned channel or an empty channel
|
||||
|
||||
if (!claimsInChannel || !claimsInChannel.length) {
|
||||
return;
|
||||
} // Determine if the latest subscription currently saved is actually the latest subscription
|
||||
|
||||
|
||||
const latestIndex = claimsInChannel.findIndex(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
|
||||
const latestIndex = claimsInChannel.findIndex(claim => claim.permanent_url === savedSubscription.latest); // 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; // If latest is 0, nothing has changed
|
||||
// Do not download/notify about new content, it would download/notify 10 claims per channel
|
||||
|
@ -1589,10 +1589,7 @@ const doCheckSubscription = (subscriptionUri, shouldNotify) => (dispatch, getSta
|
|||
let downloadCount = 0;
|
||||
const newUnread = [];
|
||||
claimsInChannel.slice(0, latestIndexToNotify).forEach(claim => {
|
||||
const uri = lbryRedux.buildURI({
|
||||
claimName: claim.name,
|
||||
claimId: claim.claim_id
|
||||
}, true);
|
||||
const uri = claim.permanent_url;
|
||||
|
||||
if (shouldNotify) {
|
||||
newUnread.push(uri);
|
||||
|
@ -1603,18 +1600,11 @@ const doCheckSubscription = (subscriptionUri, shouldNotify) => (dispatch, getSta
|
|||
// This allows the app to know if there has been new content since it was last set
|
||||
|
||||
|
||||
const latestClaim = claimsInChannel[0];
|
||||
const latestClaimChannel = latestClaim.signing_channel.name;
|
||||
const latest = claimsInChannel[0];
|
||||
dispatch(setSubscriptionLatest({
|
||||
channelName: latestClaimChannel,
|
||||
uri: lbryRedux.buildURI({
|
||||
channelName: latestClaimChannel,
|
||||
claimId: latestClaim.claim_id
|
||||
}, false)
|
||||
}, lbryRedux.buildURI({
|
||||
claimName: latestClaim.name,
|
||||
claimId: latestClaim.claim_id
|
||||
}, false))); // calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED
|
||||
channelName: latest.signing_channel.name,
|
||||
uri: latest.signing_channel.permanent_url
|
||||
}, latest.permanent_url)); // calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED
|
||||
// means it will delete a non-existant fetchingChannelClaims[uri]
|
||||
|
||||
dispatch({
|
||||
|
@ -1647,12 +1637,12 @@ const doChannelSubscribe = subscription => (dispatch, getState) => {
|
|||
|
||||
if (isSharingData) {
|
||||
const {
|
||||
claimId
|
||||
channelClaimId
|
||||
} = lbryRedux.parseURI(subscription.uri); // They are sharing data, we can store their subscriptions in our internal database
|
||||
|
||||
Lbryio.call('subscription', 'new', {
|
||||
channel_name: subscription.channelName,
|
||||
claim_id: claimId
|
||||
claim_id: channelClaimId
|
||||
});
|
||||
dispatch(doClaimRewardType(rewards.TYPE_SUBSCRIPTION, {
|
||||
failSilently: true
|
||||
|
@ -1675,10 +1665,10 @@ const doChannelUnsubscribe = subscription => (dispatch, getState) => {
|
|||
|
||||
if (isSharingData) {
|
||||
const {
|
||||
claimId
|
||||
channelClaimId
|
||||
} = lbryRedux.parseURI(subscription.uri);
|
||||
Lbryio.call('subscription', 'delete', {
|
||||
claim_id: claimId
|
||||
claim_id: channelClaimId
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1727,16 +1717,9 @@ const doFetchMySubscriptions = () => (dispatch, getState) => {
|
|||
});
|
||||
reduxSubscriptions.forEach(sub => {
|
||||
const {
|
||||
claimId
|
||||
channelClaimId
|
||||
} = lbryRedux.parseURI(sub.uri);
|
||||
reduxSubMap[claimId] = 1;
|
||||
|
||||
if (!dbSubMap[claimId]) {
|
||||
subsNotInDB.push({
|
||||
claim_id: claimId,
|
||||
channel_name: sub.channelName
|
||||
});
|
||||
}
|
||||
reduxSubMap[channelClaimId] = 1;
|
||||
});
|
||||
storedSubscriptions.forEach(sub => {
|
||||
if (!reduxSubMap[sub.claim_id]) {
|
||||
|
|
53
dist/bundle.js
vendored
53
dist/bundle.js
vendored
|
@ -2575,12 +2575,12 @@ var doCheckSubscription = function doCheckSubscription(subscriptionUri, shouldNo
|
|||
|
||||
lbry_redux__WEBPACK_IMPORTED_MODULE_3__["Lbry"].claim_search({
|
||||
channel: subscriptionUri,
|
||||
page: 1,
|
||||
page_size: constants_claim__WEBPACK_IMPORTED_MODULE_0__["PAGE_SIZE"],
|
||||
valid_channel_signature: true,
|
||||
order_by: ['release_time']
|
||||
}).then(function (result) {
|
||||
var claimsInChannel = result.items; // may happen if subscribed to an abandoned channel or an empty channel
|
||||
order_by: ['release_time'],
|
||||
page: 1,
|
||||
page_size: constants_claim__WEBPACK_IMPORTED_MODULE_0__["PAGE_SIZE"]
|
||||
}).then(function (claimListByChannel) {
|
||||
var claimsInChannel = claimListByChannel.items; // may happen if subscribed to an abandoned channel or an empty channel
|
||||
|
||||
if (!claimsInChannel || !claimsInChannel.length) {
|
||||
return;
|
||||
|
@ -2588,7 +2588,7 @@ var doCheckSubscription = function doCheckSubscription(subscriptionUri, shouldNo
|
|||
|
||||
|
||||
var latestIndex = claimsInChannel.findIndex(function (claim) {
|
||||
return "".concat(claim.name, "#").concat(claim.claim_id) === savedSubscription.latest;
|
||||
return claim.permanent_url === savedSubscription.latest;
|
||||
}); // If latest is -1, it is a newly subscribed channel or there have been 10+ claims published since last viewed
|
||||
|
||||
var latestIndexToNotify = latestIndex === -1 ? 10 : latestIndex; // If latest is 0, nothing has changed
|
||||
|
@ -2598,11 +2598,8 @@ var doCheckSubscription = function doCheckSubscription(subscriptionUri, shouldNo
|
|||
var downloadCount = 0;
|
||||
var newUnread = [];
|
||||
claimsInChannel.slice(0, latestIndexToNotify).forEach(function (claim) {
|
||||
var uri = Object(lbry_redux__WEBPACK_IMPORTED_MODULE_3__["buildURI"])({
|
||||
claimName: claim.name,
|
||||
claimId: claim.claim_id
|
||||
}, true);
|
||||
var shouldDownload = shouldAutoDownload && Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.stream.metadata.fee); // Add the new content to the list of "un-read" subscriptions
|
||||
var uri = claim.permanent_url;
|
||||
var shouldDownload = shouldAutoDownload && Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.fee); // Add the new content to the list of "un-read" subscriptions
|
||||
|
||||
if (shouldNotify) {
|
||||
newUnread.push(uri);
|
||||
|
@ -2620,18 +2617,11 @@ var doCheckSubscription = function doCheckSubscription(subscriptionUri, shouldNo
|
|||
// This allows the app to know if there has been new content since it was last set
|
||||
|
||||
|
||||
var latestClaim = claimsInChannel[0];
|
||||
var latestClaimChannel = latestClaim.signing_channel.name;
|
||||
var latest = claimsInChannel[0];
|
||||
dispatch(setSubscriptionLatest({
|
||||
channelName: latestClaimChannel,
|
||||
uri: Object(lbry_redux__WEBPACK_IMPORTED_MODULE_3__["buildURI"])({
|
||||
channelName: latestClaimChannel,
|
||||
claimId: latestClaim.claim_id
|
||||
}, false)
|
||||
}, Object(lbry_redux__WEBPACK_IMPORTED_MODULE_3__["buildURI"])({
|
||||
claimName: latestClaim.name,
|
||||
claimId: latestClaim.claim_id
|
||||
}, false))); // calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED
|
||||
channelName: latest.signing_channel.name,
|
||||
uri: latest.signing_channel.permanent_url
|
||||
}, latest.permanent_url)); // calling FETCH_CHANNEL_CLAIMS_COMPLETED after not calling STARTED
|
||||
// means it will delete a non-existant fetchingChannelClaims[uri]
|
||||
|
||||
dispatch({
|
||||
|
@ -2664,12 +2654,12 @@ var doChannelSubscribe = function doChannelSubscribe(subscription) {
|
|||
|
||||
if (isSharingData) {
|
||||
var _parseURI = Object(lbry_redux__WEBPACK_IMPORTED_MODULE_3__["parseURI"])(subscription.uri),
|
||||
claimId = _parseURI.claimId; // They are sharing data, we can store their subscriptions in our internal database
|
||||
channelClaimId = _parseURI.channelClaimId; // They are sharing data, we can store their subscriptions in our internal database
|
||||
|
||||
|
||||
lbryio__WEBPACK_IMPORTED_MODULE_6__["default"].call('subscription', 'new', {
|
||||
channel_name: subscription.channelName,
|
||||
claim_id: claimId
|
||||
claim_id: channelClaimId
|
||||
});
|
||||
dispatch(Object(redux_actions_rewards__WEBPACK_IMPORTED_MODULE_1__["doClaimRewardType"])(rewards__WEBPACK_IMPORTED_MODULE_7__["default"].TYPE_SUBSCRIPTION, {
|
||||
failSilently: true
|
||||
|
@ -2692,10 +2682,10 @@ var doChannelUnsubscribe = function doChannelUnsubscribe(subscription) {
|
|||
|
||||
if (isSharingData) {
|
||||
var _parseURI2 = Object(lbry_redux__WEBPACK_IMPORTED_MODULE_3__["parseURI"])(subscription.uri),
|
||||
claimId = _parseURI2.claimId;
|
||||
channelClaimId = _parseURI2.channelClaimId;
|
||||
|
||||
lbryio__WEBPACK_IMPORTED_MODULE_6__["default"].call('subscription', 'delete', {
|
||||
claim_id: claimId
|
||||
claim_id: channelClaimId
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -2746,16 +2736,9 @@ var doFetchMySubscriptions = function doFetchMySubscriptions() {
|
|||
});
|
||||
reduxSubscriptions.forEach(function (sub) {
|
||||
var _parseURI3 = Object(lbry_redux__WEBPACK_IMPORTED_MODULE_3__["parseURI"])(sub.uri),
|
||||
claimId = _parseURI3.claimId;
|
||||
channelClaimId = _parseURI3.channelClaimId;
|
||||
|
||||
reduxSubMap[claimId] = 1;
|
||||
|
||||
if (!dbSubMap[claimId]) {
|
||||
subsNotInDB.push({
|
||||
claim_id: claimId,
|
||||
channel_name: sub.channelName
|
||||
});
|
||||
}
|
||||
reduxSubMap[channelClaimId] = 1;
|
||||
});
|
||||
storedSubscriptions.forEach(function (sub) {
|
||||
if (!reduxSubMap[sub.claim_id]) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import type {
|
|||
import { PAGE_SIZE } from 'constants/claim';
|
||||
import { doClaimRewardType } from 'redux/actions/rewards';
|
||||
import { selectSubscriptions, selectUnreadByChannel } from 'redux/selectors/subscriptions';
|
||||
import { Lbry, buildURI, parseURI, doResolveUris, doPurchaseUri } from 'lbry-redux';
|
||||
import { Lbry, parseURI, doResolveUris, doPurchaseUri } from 'lbry-redux';
|
||||
import * as ACTIONS from 'constants/action_types';
|
||||
import * as NOTIFICATION_TYPES from 'constants/subscriptions';
|
||||
import Lbryio from 'lbryio';
|
||||
|
@ -159,12 +159,12 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
|
|||
// We may be duplicating calls here. Can this logic be baked into doFetchClaimsByChannel?
|
||||
Lbry.claim_search({
|
||||
channel: subscriptionUri,
|
||||
page: 1,
|
||||
page_size: PAGE_SIZE,
|
||||
valid_channel_signature: true,
|
||||
order_by: ['release_time'],
|
||||
}).then(result => {
|
||||
const { items: claimsInChannel } = result;
|
||||
page: 1,
|
||||
page_size: PAGE_SIZE,
|
||||
}).then(claimListByChannel => {
|
||||
const { items: claimsInChannel } = claimListByChannel;
|
||||
|
||||
// may happen if subscribed to an abandoned channel or an empty channel
|
||||
if (!claimsInChannel || !claimsInChannel.length) {
|
||||
|
@ -173,7 +173,7 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
|
|||
|
||||
// Determine if the latest subscription currently saved is actually the latest subscription
|
||||
const latestIndex = claimsInChannel.findIndex(
|
||||
claim => `${claim.name}#${claim.claim_id}` === savedSubscription.latest
|
||||
claim => claim.permanent_url === savedSubscription.latest
|
||||
);
|
||||
|
||||
// If latest is -1, it is a newly subscribed channel or there have been 10+ claims published since last viewed
|
||||
|
@ -186,10 +186,10 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
|
|||
|
||||
const newUnread = [];
|
||||
claimsInChannel.slice(0, latestIndexToNotify).forEach(claim => {
|
||||
const uri = buildURI({ claimName: claim.name, claimId: claim.claim_id }, true);
|
||||
const uri = claim.permanent_url;
|
||||
const shouldDownload =
|
||||
shouldAutoDownload &&
|
||||
Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.stream.metadata.fee);
|
||||
Boolean(downloadCount < SUBSCRIPTION_DOWNLOAD_LIMIT && !claim.value.fee);
|
||||
|
||||
// Add the new content to the list of "un-read" subscriptions
|
||||
if (shouldNotify) {
|
||||
|
@ -213,21 +213,14 @@ export const doCheckSubscription = (subscriptionUri: string, shouldNotify?: bool
|
|||
|
||||
// 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
|
||||
const latestClaim = claimsInChannel[0];
|
||||
const latestClaimChannel = latestClaim.signing_channel.name;
|
||||
const latest = claimsInChannel[0];
|
||||
dispatch(
|
||||
setSubscriptionLatest(
|
||||
{
|
||||
channelName: latestClaimChannel,
|
||||
uri: buildURI(
|
||||
{
|
||||
channelName: latestClaimChannel,
|
||||
claimId: latestClaim.claim_id,
|
||||
},
|
||||
false
|
||||
),
|
||||
channelName: latest.signing_channel.name,
|
||||
uri: latest.signing_channel.permanent_url,
|
||||
},
|
||||
buildURI({ claimName: latestClaim.name, claimId: latestClaim.claim_id }, false)
|
||||
latest.permanent_url
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -268,11 +261,11 @@ export const doChannelSubscribe = (subscription: Subscription) => (
|
|||
|
||||
// if the user isn't sharing data, keep the subscriptions entirely in the app
|
||||
if (isSharingData) {
|
||||
const { claimId } = parseURI(subscription.uri);
|
||||
const { channelClaimId } = parseURI(subscription.uri);
|
||||
// They are sharing data, we can store their subscriptions in our internal database
|
||||
Lbryio.call('subscription', 'new', {
|
||||
channel_name: subscription.channelName,
|
||||
claim_id: claimId,
|
||||
claim_id: channelClaimId,
|
||||
});
|
||||
|
||||
dispatch(doClaimRewardType(rewards.TYPE_SUBSCRIPTION, { failSilently: true }));
|
||||
|
@ -296,9 +289,9 @@ export const doChannelUnsubscribe = (subscription: Subscription) => (
|
|||
});
|
||||
|
||||
if (isSharingData) {
|
||||
const { claimId } = parseURI(subscription.uri);
|
||||
const { channelClaimId } = parseURI(subscription.uri);
|
||||
Lbryio.call('subscription', 'delete', {
|
||||
claim_id: claimId,
|
||||
claim_id: channelClaimId,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -354,15 +347,8 @@ export const doFetchMySubscriptions = () => (dispatch: ReduxDispatch, getState:
|
|||
});
|
||||
|
||||
reduxSubscriptions.forEach(sub => {
|
||||
const { claimId } = parseURI(sub.uri);
|
||||
reduxSubMap[claimId] = 1;
|
||||
|
||||
if (!dbSubMap[claimId]) {
|
||||
subsNotInDB.push({
|
||||
claim_id: claimId,
|
||||
channel_name: sub.channelName,
|
||||
});
|
||||
}
|
||||
const { channelClaimId } = parseURI(sub.uri);
|
||||
reduxSubMap[channelClaimId] = 1;
|
||||
});
|
||||
|
||||
storedSubscriptions.forEach(sub => {
|
||||
|
|
Loading…
Reference in a new issue