make sure the app doesn't autoplay paid content, channels, or content from blocked channels
This commit is contained in:
parent
dacdc59b93
commit
cdc76e3d95
1 changed files with 36 additions and 5 deletions
|
@ -7,7 +7,10 @@ import {
|
||||||
makeSelectClaimIsNsfw,
|
makeSelectClaimIsNsfw,
|
||||||
makeSelectRecommendedContentForUri,
|
makeSelectRecommendedContentForUri,
|
||||||
makeSelectMediaTypeForUri,
|
makeSelectMediaTypeForUri,
|
||||||
|
selectBlockedChannels,
|
||||||
|
parseURI,
|
||||||
} from 'lbry-redux';
|
} from 'lbry-redux';
|
||||||
|
import { selectAllCostInfoByUri } from 'lbryinc';
|
||||||
import { selectShowMatureContent } from 'redux/selectors/settings';
|
import { selectShowMatureContent } from 'redux/selectors/settings';
|
||||||
|
|
||||||
const RECENT_HISTORY_AMOUNT = 10;
|
const RECENT_HISTORY_AMOUNT = 10;
|
||||||
|
@ -77,11 +80,39 @@ export const makeSelectNextUnplayedRecommended = (uri: string) =>
|
||||||
createSelector(
|
createSelector(
|
||||||
makeSelectRecommendedContentForUri(uri),
|
makeSelectRecommendedContentForUri(uri),
|
||||||
selectHistory,
|
selectHistory,
|
||||||
(possibleNext, history) => {
|
selectClaimsByUri,
|
||||||
if (possibleNext) {
|
selectAllCostInfoByUri,
|
||||||
for (let i = 0; i < possibleNext.length; i++) {
|
selectBlockedChannels,
|
||||||
if (!history.find(item => item.uri === possibleNext[i])) {
|
(
|
||||||
return possibleNext[i];
|
recommendedForUri: Array<string>,
|
||||||
|
history: Array<{ uri: string }>,
|
||||||
|
claimsByUri: { [string]: ?Claim },
|
||||||
|
costInfoByUri: { [string]: { cost: 0 | string } },
|
||||||
|
blockedChannels: Array<string>
|
||||||
|
) => {
|
||||||
|
if (recommendedForUri) {
|
||||||
|
// Make sure we don't autoplay paid content, channels, or content from blocked channels
|
||||||
|
for (let i = 0; i < recommendedForUri.length; i++) {
|
||||||
|
const recommendedUri = recommendedForUri[i];
|
||||||
|
|
||||||
|
const { isChannel } = parseURI(recommendedUri);
|
||||||
|
if (isChannel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const costInfo = costInfoByUri[recommendedUri];
|
||||||
|
if (!costInfo || costInfo.cost !== 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const claim = claimsByUri[recommendedUri];
|
||||||
|
const channel = claim && claim.signing_channel;
|
||||||
|
if (channel && blockedChannels.find(blockedUri => blockedUri === channel.permanent_url)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!history.find(item => item.uri === recommendedForUri[i])) {
|
||||||
|
return recommendedForUri[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue