Show premium ads for users outside the US (#1521)

This commit is contained in:
Rave | 図書館猫 2022-05-18 16:05:58 +02:00 committed by GitHub
parent ffdb5abf63
commit c16516fab5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 7 deletions

View file

@ -9,7 +9,7 @@ import { selectFollowedTags } from 'redux/selectors/tags';
import { doToggleTagFollowDesktop } from 'redux/actions/tags'; import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { selectClientSetting, selectLanguage } from 'redux/selectors/settings'; import { selectClientSetting, selectLanguage } from 'redux/selectors/settings';
import { selectAdBlockerFound } from 'redux/selectors/app'; import { selectAdBlockerFound } from 'redux/selectors/app';
import { selectOdyseeMembershipIsPremiumPlus } from 'redux/selectors/user'; import { selectOdyseeMembershipIsPremiumPlus, selectUserCountry } from 'redux/selectors/user';
import DiscoverPage from './view'; import DiscoverPage from './view';
const select = (state, props) => { const select = (state, props) => {
@ -27,6 +27,7 @@ const select = (state, props) => {
searchInLanguage: selectClientSetting(state, SETTINGS.SEARCH_IN_LANGUAGE), searchInLanguage: selectClientSetting(state, SETTINGS.SEARCH_IN_LANGUAGE),
adBlockerFound: selectAdBlockerFound(state), adBlockerFound: selectAdBlockerFound(state),
hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state), hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state),
userCountry: selectUserCountry(state),
}; };
}; };

View file

@ -38,6 +38,7 @@ type Props = {
doFetchActiveLivestreams: (orderBy: ?Array<string>, lang: ?Array<string>) => void, doFetchActiveLivestreams: (orderBy: ?Array<string>, lang: ?Array<string>) => void,
adBlockerFound: ?boolean, adBlockerFound: ?boolean,
hasPremiumPlus: ?boolean, hasPremiumPlus: ?boolean,
userCountry: string,
}; };
function DiscoverPage(props: Props) { function DiscoverPage(props: Props) {
@ -56,6 +57,7 @@ function DiscoverPage(props: Props) {
dynamicRouteProps, dynamicRouteProps,
adBlockerFound, adBlockerFound,
hasPremiumPlus, hasPremiumPlus,
userCountry,
} = props; } = props;
const buttonRef = useRef(); const buttonRef = useRef();
@ -63,6 +65,7 @@ function DiscoverPage(props: Props) {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
const isWildWest = dynamicRouteProps && dynamicRouteProps.id === 'WILD_WEST'; const isWildWest = dynamicRouteProps && dynamicRouteProps.id === 'WILD_WEST';
const isCategory = Boolean(dynamicRouteProps); const isCategory = Boolean(dynamicRouteProps);
const userIsInUS = userCountry === 'US';
const urlParams = new URLSearchParams(search); const urlParams = new URLSearchParams(search);
const langParam = urlParams.get(CS.LANGUAGE_KEY) || null; const langParam = urlParams.get(CS.LANGUAGE_KEY) || null;
@ -229,7 +232,8 @@ function DiscoverPage(props: Props) {
injectedItem={ injectedItem={
!isWildWest && !isWildWest &&
!hasPremiumPlus && { !hasPremiumPlus && {
node: adBlockerFound ? ( node:
adBlockerFound || !userIsInUS ? (
<PremiumPlusTile tileLayout={tileLayout} /> <PremiumPlusTile tileLayout={tileLayout} />
) : ( ) : (
<Ads small type="video" tileLayout /> <Ads small type="video" tileLayout />

View file

@ -10,6 +10,7 @@ import {
selectHasOdyseeMembership, selectHasOdyseeMembership,
selectHomepageFetched, selectHomepageFetched,
selectUserVerifiedEmail, selectUserVerifiedEmail,
selectUserCountry,
} from 'redux/selectors/user'; } from 'redux/selectors/user';
import { selectSubscriptions } from 'redux/selectors/subscriptions'; import { selectSubscriptions } from 'redux/selectors/subscriptions';
import { import {
@ -36,6 +37,7 @@ const select = (state) => ({
homepageOrder: selectClientSetting(state, SETTINGS.HOMEPAGE_ORDER), homepageOrder: selectClientSetting(state, SETTINGS.HOMEPAGE_ORDER),
hasMembership: selectHasOdyseeMembership(state), hasMembership: selectHasOdyseeMembership(state),
hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state), hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state),
userCountry: selectUserCountry(state),
}); });
const perform = (dispatch) => ({ const perform = (dispatch) => ({

View file

@ -48,6 +48,7 @@ type Props = {
doOpenModal: (id: string, ?{}) => void, doOpenModal: (id: string, ?{}) => void,
hasMembership: ?boolean, hasMembership: ?boolean,
hasPremiumPlus: ?boolean, hasPremiumPlus: ?boolean,
userCountry: string,
}; };
function HomePage(props: Props) { function HomePage(props: Props) {
@ -68,6 +69,7 @@ function HomePage(props: Props) {
doOpenModal, doOpenModal,
hasMembership, hasMembership,
hasPremiumPlus, hasPremiumPlus,
userCountry,
} = props; } = props;
const showPersonalizedChannels = (authenticated || !IS_WEB) && subscribedChannels && subscribedChannels.length > 0; const showPersonalizedChannels = (authenticated || !IS_WEB) && subscribedChannels && subscribedChannels.length > 0;
@ -75,6 +77,7 @@ function HomePage(props: Props) {
const showIndividualTags = showPersonalizedTags && followedTags.length < 5; const showIndividualTags = showPersonalizedTags && followedTags.length < 5;
const isLargeScreen = useIsLargeScreen(); const isLargeScreen = useIsLargeScreen();
const channelIds = subscribedChannels.map((sub) => splitBySeparator(sub.uri)[1]); const channelIds = subscribedChannels.map((sub) => splitBySeparator(sub.uri)[1]);
const userIsInUS = userCountry === 'US';
const rowData: Array<RowDataItem> = GetLinksData( const rowData: Array<RowDataItem> = GetLinksData(
homepageData, homepageData,
@ -168,7 +171,8 @@ function HomePage(props: Props) {
injectedItem={ injectedItem={
index === 0 && index === 0 &&
!hasPremiumPlus && { !hasPremiumPlus && {
node: adBlockerFound ? <PremiumPlusTile tileLayout /> : <Ads small type="video" tileLayout />, node:
adBlockerFound || !userIsInUS ? <PremiumPlusTile tileLayout /> : <Ads small type="video" tileLayout />,
} }
} }
forceShowReposts={id !== 'FOLLOWING'} forceShowReposts={id !== 'FOLLOWING'}