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

View file

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

View file

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

View file

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