Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ad injections & premium checks #3131

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ui/component/recommendedContent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { withRouter } from 'react-router';
import { selectClaimForUri } from 'redux/selectors/claims';
import { doFetchRecommendedContent } from 'redux/actions/search';
import { selectRecommendedContentForUri, selectIsSearching } from 'redux/selectors/search';
import { selectUserHasOdyseePremiumPlus } from 'redux/selectors/memberships';
import RecommendedContent from './view';
import { selectClientSetting } from 'redux/selectors/settings';
import * as SETTINGS from 'constants/settings';
Expand All @@ -18,7 +17,6 @@ const select = (state, props) => {
nextRecommendedUri,
isSearching: selectIsSearching(state),
searchInLanguage: selectClientSetting(state, SETTINGS.SEARCH_IN_LANGUAGE),
hasPremiumPlus: selectUserHasOdyseePremiumPlus(state),
};
};

Expand Down
40 changes: 0 additions & 40 deletions ui/component/recommendedContent/view.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
// @flow
import { v4 as Uuidv4 } from 'uuid';
import { SHOW_ADS, AD_KEYWORD_BLOCKLIST, AD_KEYWORD_BLOCKLIST_CHECK_DESCRIPTION } from 'config';
import React from 'react';
import ClaimList from 'component/claimList';
import ClaimListDiscover from 'component/claimListDiscover';
import ClaimPreview from 'component/claimPreview';
import Ad from 'web/component/ad';
import Card from 'component/common/card';
import { useIsMobile, useIsMediumScreen } from 'effects/use-screensize';
import Button from 'component/button';
import { FYP_ID } from 'constants/urlParams';
import classnames from 'classnames';
import RecSys from 'recsys';
import LangFilterIndicator from 'component/langFilterIndicator';
import { getClaimMetadata } from 'util/claim';
import './style.scss';

const VIEW_ALL_RELATED = 'view_all_related';
const VIEW_MORE_FROM = 'view_more_from';
const BLOCKED_WORDS: ?Array<string> = AD_KEYWORD_BLOCKLIST && AD_KEYWORD_BLOCKLIST.toLowerCase().split(',');
const CHECK_DESCRIPTION: boolean = AD_KEYWORD_BLOCKLIST_CHECK_DESCRIPTION === 'true';

type Props = {
uri: string,
Expand All @@ -32,7 +27,6 @@ type Props = {
claimId: string,
metadata: any,
location: UrlLocation,
hasPremiumPlus: boolean,
};

export default React.memo<Props>(function RecommendedContent(props: Props) {
Expand All @@ -45,33 +39,9 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
searchInLanguage,
claim,
location,
hasPremiumPlus,
} = props;

const claimId: ?string = claim && claim.claim_id;
const injectAds = SHOW_ADS && IS_WEB && !hasPremiumPlus;

function claimContainsBlockedWords(claim: ?StreamClaim) {
if (BLOCKED_WORDS) {
const hasBlockedWords = (str) => BLOCKED_WORDS.some((bw) => str.includes(bw));
const metadata = getClaimMetadata(claim);
// $FlowFixMe - flow does not support chaining yet, but we know for sure these fields are '?string'.
const title = metadata?.title?.toLowerCase();
// $FlowFixMe
const description = metadata?.description?.toLowerCase();
// $FlowFixMe
const name = claim?.name?.toLowerCase();

return Boolean(
(title && hasBlockedWords(title)) ||
(name && hasBlockedWords(name)) ||
(CHECK_DESCRIPTION && description && hasBlockedWords(description))
);
}
return false;
}

const blacklistTriggered = React.useMemo(() => injectAds && claimContainsBlockedWords(claim), [injectAds, claim]);

const [viewMode, setViewMode] = React.useState(VIEW_ALL_RELATED);
const signingChannel = claim && claim.signing_channel;
Expand All @@ -80,14 +50,6 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
const isMedium = useIsMediumScreen();
const { onRecsLoaded: onRecommendationsLoaded, onClickedRecommended: onRecommendationClicked } = RecSys;

const InjectedAd =
injectAds && !blacklistTriggered && !hasPremiumPlus
? {
node: <Ad type="tileB" uri={uri} />,
index: isMobile ? 0 : 3,
}
: null;

// Assume this component always resides in a page where the `uri` matches
// e.g. never in a floating popup. With that, we can grab the FYP ID from
// the search param directly. Otherwise, the parent component would need to
Expand Down Expand Up @@ -165,7 +127,6 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
type="small"
loading={isSearching}
uris={recommendedContentUris}
injectedItem={InjectedAd}
empty={__('No related content found')}
onClick={handleRecommendationClicked}
/>
Expand All @@ -183,7 +144,6 @@ export default React.memo<Props>(function RecommendedContent(props: Props) {
hideFilters
channelIds={[signingChannel.claim_id]}
loading={isSearching}
injectedItem={InjectedAd}
empty={__('No related content found')}
/>
)}
Expand Down
9 changes: 0 additions & 9 deletions ui/component/sideNavigation/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,6 @@ function SideNavigation(props: Props) {
gdprDiv.style.display = 'none';
}
}

const ad = document.getElementById('rmbl-sticky') || document.getElementById('sticky-d-rc');
if (ad) {
if (!sidebarOpen || isMobile) {
ad.classList.remove('LEFT');
} else {
ad.classList.add('LEFT');
}
}
}, [sidebarOpen, isMobile]);

React.useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
makeSelectTotalPagesInChannelSearch,
selectClaimForUri,
} from 'redux/selectors/claims';
import { selectUserHasOdyseePremiumPlus } from 'redux/selectors/memberships';
import { doResolveUris } from 'redux/actions/claims';
import * as SETTINGS from 'constants/settings';
import { makeSelectChannelIsMuted } from 'redux/selectors/blocked';
Expand Down Expand Up @@ -37,7 +36,6 @@ const select = (state, props) => {
hideShorts: selectClientSetting(state, SETTINGS.HIDE_SHORTS),
activeLivestreamForChannel: selectActiveLivestreamForChannel(state, channelClaimId),
adBlockerFound: selectAdBlockerFound(state),
hasPremiumPlus: selectUserHasOdyseePremiumPlus(state),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { ClaimSearchFilterContext } from 'contexts/claimSearchFilterContext';
import { SearchResults } from './internal/searchResults';
import { useIsLargeScreen } from 'effects/use-screensize';
import usePersistedState from 'effects/use-persisted-state';
import Ad from 'web/component/ad';
import { tagSearchCsOptionsHook } from 'util/search';
import { lazyImport } from 'util/lazyImport';

Expand Down Expand Up @@ -50,7 +49,6 @@ type Props = {
claimType: string,
empty?: string,
activeLivestreamForChannel: ?LivestreamActiveClaim,
hasPremiumPlus: boolean,
};

function ContentTab(props: Props) {
Expand All @@ -72,7 +70,6 @@ function ContentTab(props: Props) {
claimType,
empty,
activeLivestreamForChannel,
hasPremiumPlus,
} = props;

const claimsInChannel = 9999;
Expand Down Expand Up @@ -187,17 +184,6 @@ function ContentTab(props: Props) {
defaultOrderBy={filters ? filters.order_by : CS.ORDER_BY_NEW}
pageSize={dynamicPageSize}
infiniteScroll={defaultInfiniteScroll}
injectedItem={
!hasPremiumPlus && {
node: (index, lastVisibleIndex, pageSize) => {
if (pageSize && index < pageSize) {
return index === lastVisibleIndex ? <Ad type="tileA" tileLayout={tileLayout} /> : null;
} else {
return index % (pageSize * 2) === 0 ? <Ad type="tileA" tileLayout={tileLayout} /> : null;
}
},
}
}
meta={
showFilters && (
<Form onSubmit={() => {}} className="wunderbar--inline">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ import {
selectClaimIdsForCollectionId,
} from 'redux/selectors/collections';
import { SECTION_TAGS } from 'constants/collections';
import { selectUserHasOdyseePremiumPlus } from 'redux/selectors/memberships';
import { selectFeaturedChannelsForChannelId } from 'redux/selectors/comments';
import { CsOptHelper } from 'util/claim-search';
import HomeTabSection from './view';
import * as CS from 'constants/claim_search';

const select = (state, props) => {
const hasPremiumPlus = selectUserHasOdyseePremiumPlus(state);
const stream_types =
props.section.file_type && Array.isArray(props.section.file_type)
? props.section.file_type
Expand All @@ -32,7 +30,7 @@ const select = (state, props) => {
const claimType =
props.section.type === 'playlists' ? 'collection' : props.section.type === 'reposts' ? 'repost' : 'stream';
const options = {
page_size: props.section.type !== 'featured' ? (hasPremiumPlus ? 12 : 11) : 1,
page_size: props.section.type !== 'featured' ? 12 : 1,
page: 1,
channel_ids: [props.channelClaimId],
stream_types: props.section.type !== 'reposts' ? stream_types : undefined,
Expand Down Expand Up @@ -81,7 +79,6 @@ const select = (state, props) => {
props.section.type === 'featured' && props.section.claim_id && selectClaimUriForId(state, props.section.claim_id),
featuredChannels: selectFeaturedChannelsForChannelId(state, props.channelClaimId),
activeLivestreamUri: activeLivestream?.uri,
hasPremiumPlus,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { DEBOUNCE_WAIT_DURATION_MS, SEARCH_PAGE_SIZE } from 'constants/search';
import ChannelSection from 'component/channelSections/Section';
import UpcomingClaims from 'component/upcomingClaims';
import ClaimPreviewTile from 'component/claimPreviewTile';
import Ad from 'web/component/ad';
import { lighthouse } from 'redux/actions/search';
import * as CS from 'constants/claim_search';
import Icon from 'component/common/icon';
Expand Down Expand Up @@ -35,7 +34,6 @@ type Props = {
singleClaimUri: string,
featuredChannels: any,
activeLivestreamUri: ?ClaimUri,
hasPremiumPlus: boolean,
// --- perform ---
doClaimSearch: (ClaimSearchOptions, ?DoClaimSearchSettings) => Promise<any>,
doResolveClaimId: (claimId: string) => void,
Expand All @@ -47,7 +45,6 @@ function HomeTabSection(props: Props) {
const {
channelClaimId,
index,
topContentGridIndex,
section,
editMode,
hasFeaturedContent,
Expand All @@ -62,7 +59,6 @@ function HomeTabSection(props: Props) {
fetchingClaimSearch,
publishedCollections,
singleClaimUri,
hasPremiumPlus,
featuredChannels,
activeLivestreamUri,
doClaimSearch,
Expand All @@ -79,7 +75,6 @@ function HomeTabSection(props: Props) {
const maxClaimsInSection = 12;

const windowSize = useWindowSize();
const maxTilesPerRow = windowSize >= 1600 ? 6 : windowSize > 1150 ? 4 : windowSize > 900 ? 3 : 2;
const maxChannelsPerRow = windowSize >= 1150 ? 8 : windowSize > 900 ? 6 : 3;
const featuredChannel = featuredChannels && featuredChannels.find((list) => list.id === section.claim_id);
const hasFeaturedClaim = singleClaimUri || (claimSearchResults && claimSearchResults[0]) || section.claim_id;
Expand Down Expand Up @@ -425,14 +420,6 @@ function HomeTabSection(props: Props) {
uris={collectionUrls || claimSearchResults}
maxClaimRender={maxClaimsInSection}
claimIds={collectionClaimIds}
injectedItem={
!hasPremiumPlus &&
index === topContentGridIndex && {
node: (index) => {
return index === maxTilesPerRow ? <Ad type="tileA" tileLayout /> : null;
},
}
}
/>
)
: featuredChannel && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import { LINKED_COMMENT_QUERY_PARAM, THREAD_COMMENT_QUERY_PARAM } from 'constant

import { selectCommentsDisabledSettingForChannelId } from 'redux/selectors/comments';
import { selectClaimIsNsfwForUri, selectClaimForUri } from 'redux/selectors/claims';
import {
selectUserHasOdyseePremiumPlus,
selectNoRestrictionOrUserIsMemberForContentClaimId,
} from 'redux/selectors/memberships';
import { selectNoRestrictionOrUserIsMemberForContentClaimId } from 'redux/selectors/memberships';
import { getChannelIdFromClaim } from 'util/claim';

import MarkdownPostPage from './view';
Expand All @@ -27,7 +24,6 @@ const select = (state, props) => {
threadCommentId: urlParams.get(THREAD_COMMENT_QUERY_PARAM),
contentUnlocked: claimId && selectNoRestrictionOrUserIsMemberForContentClaimId(state, claimId),
commentSettingDisabled: selectCommentsDisabledSettingForChannelId(state, getChannelIdFromClaim(claim)),
hasPremiumPlus: selectUserHasOdyseePremiumPlus(state),
};
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @flow
import * as React from 'react';
import Ad from 'web/component/ad';
import Empty from 'component/common/empty';
import FileTitleSection from 'component/fileTitleSection';
import { lazyImport } from 'util/lazyImport';
Expand All @@ -17,7 +16,6 @@ type Props = {
threadCommentId?: string,
commentSettingDisabled: ?boolean,
contentUnlocked: boolean,
hasPremiumPlus: boolean,
};

export default function MarkdownPostPage(props: Props) {
Expand All @@ -30,7 +28,6 @@ export default function MarkdownPostPage(props: Props) {
threadCommentId,
commentSettingDisabled,
contentUnlocked,
hasPremiumPlus,
} = props;

if (isMature) {
Expand All @@ -54,7 +51,6 @@ export default function MarkdownPostPage(props: Props) {
<Empty text={__('The creator of this content has disabled comments.')} />
) : contentUnlocked ? (
<React.Suspense fallback={null}>
{!hasPremiumPlus && <Ad type="aboveComments" uri={uri} />}
<CommentsList
uri={uri}
linkedCommentId={linkedCommentId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import {
selectIsAutoplayCountdownForUri,
} from 'redux/selectors/content';
import { selectCommentsListTitleForUri, selectCommentsDisabledSettingForChannelId } from 'redux/selectors/comments';
import {
selectUserHasOdyseePremiumPlus,
selectNoRestrictionOrUserIsMemberForContentClaimId,
} from 'redux/selectors/memberships';
import { selectNoRestrictionOrUserIsMemberForContentClaimId } from 'redux/selectors/memberships';
import { clearPosition } from 'redux/actions/content';

import VideoPlayersPage from './view';
Expand Down Expand Up @@ -48,7 +45,6 @@ const select = (state, props) => {
videoTheaterMode: selectClientSetting(state, SETTINGS.VIDEO_THEATER_MODE),
contentUnlocked: claimId && selectNoRestrictionOrUserIsMemberForContentClaimId(state, claimId),
isAutoplayCountdownForUri: selectIsAutoplayCountdownForUri(state, uri),
hasPremiumPlus: selectUserHasOdyseePremiumPlus(state),
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import RecommendedContent from 'component/recommendedContent';
import Empty from 'component/common/empty';
import SwipeableDrawer from 'component/swipeableDrawer';
import DrawerExpandButton from 'component/swipeableDrawerExpand';
import Ad from 'web/component/ad';
import { useIsMobile, useIsMobileLandscape, useIsMediumScreen } from 'effects/use-screensize';

const CommentsList = lazyImport(() => import('component/commentsList' /* webpackChunkName: "comments" */));
Expand Down Expand Up @@ -40,7 +39,6 @@ type Props = {
contentUnlocked: boolean,
isAutoplayCountdownForUri: ?boolean,
clearPosition: (uri: string) => void,
hasPremiumPlus: boolean,
};

export default function VideoPlayersPage(props: Props) {
Expand All @@ -63,7 +61,6 @@ export default function VideoPlayersPage(props: Props) {
contentUnlocked,
isAutoplayCountdownForUri,
clearPosition,
hasPremiumPlus,
} = props;

const isMobile = useIsMobile();
Expand Down Expand Up @@ -146,7 +143,6 @@ export default function VideoPlayersPage(props: Props) {
<Empty padded={!isMobile} text={__('The creator of this content has disabled comments.')} />
) : isMobile && !isLandscapeRotated ? (
<React.Fragment>
{!hasPremiumPlus && <Ad type="aboveComments" uri={uri} />}
<SwipeableDrawer type={DRAWERS.CHAT} title={<h2>{commentsListTitle}</h2>}>
<React.Suspense fallback={null}>
<CommentsList {...commentsListProps} />
Expand All @@ -157,7 +153,6 @@ export default function VideoPlayersPage(props: Props) {
</React.Fragment>
) : (
<React.Suspense fallback={null}>
{!hasPremiumPlus && <Ad type="aboveComments" uri={uri} />}
<CommentsList {...commentsListProps} notInDrawer />
</React.Suspense>
))}
Expand Down
Loading
Loading