From 746d321dfec8a8fcb9e5bfbe086539428da5a3e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rave=20=7C=20=E5=9B=B3=E6=9B=B8=E9=A4=A8=E7=8C=AB?= Date: Wed, 18 May 2022 20:51:15 +0200 Subject: [PATCH] Remove Premium+ Tiles when Premium+ is active (#1525) --- ui/component/channelContent/index.js | 4 ++++ ui/component/channelContent/view.jsx | 8 +++++++- ui/component/recommendedContent/index.js | 2 +- ui/component/recommendedContent/view.jsx | 8 ++++---- ui/page/discover/index.js | 2 ++ ui/page/discover/view.jsx | 4 +++- ui/page/home/index.js | 8 +++++++- ui/page/home/view.jsx | 4 +++- ui/page/search/index.js | 3 +++ ui/page/search/view.jsx | 5 +++-- 10 files changed, 37 insertions(+), 11 deletions(-) diff --git a/ui/component/channelContent/index.js b/ui/component/channelContent/index.js index be6563eef..4d4773362 100644 --- a/ui/component/channelContent/index.js +++ b/ui/component/channelContent/index.js @@ -7,11 +7,13 @@ import { makeSelectTotalPagesInChannelSearch, selectClaimForUri, } from 'redux/selectors/claims'; +import { selectOdyseeMembershipIsPremiumPlus } from 'redux/selectors/user'; import { doResolveUris } from 'redux/actions/claims'; import * as SETTINGS from 'constants/settings'; import { makeSelectChannelIsMuted } from 'redux/selectors/blocked'; import { withRouter } from 'react-router'; import { selectClientSetting, selectShowMatureContent } from 'redux/selectors/settings'; +import { selectAdBlockerFound } from 'redux/selectors/app'; import { doFetchChannelLiveStatus } from 'redux/actions/livestream'; import { selectActiveLivestreamForChannel, selectActiveLivestreamInitialized } from 'redux/selectors/livestream'; import { getChannelIdFromClaim } from 'util/claim'; @@ -35,6 +37,8 @@ const select = (state, props) => { tileLayout: selectClientSetting(state, SETTINGS.TILE_LAYOUT), activeLivestreamForChannel: selectActiveLivestreamForChannel(state, channelClaimId), activeLivestreamInitialized: selectActiveLivestreamInitialized(state), + adBlockerFound: selectAdBlockerFound(state), + hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state), }; }; diff --git a/ui/component/channelContent/view.jsx b/ui/component/channelContent/view.jsx index 3c3e61b5c..98ba02009 100644 --- a/ui/component/channelContent/view.jsx +++ b/ui/component/channelContent/view.jsx @@ -41,6 +41,7 @@ type Props = { doFetchChannelLiveStatus: (string) => void, activeLivestreamForChannel: any, activeLivestreamInitialized: boolean, + hasPremiumPlus: boolean, }; function ChannelContent(props: Props) { @@ -62,6 +63,7 @@ function ChannelContent(props: Props) { doFetchChannelLiveStatus, activeLivestreamForChannel, activeLivestreamInitialized, + hasPremiumPlus, } = props; // const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0; @@ -159,7 +161,11 @@ function ChannelContent(props: Props) { defaultOrderBy={CS.ORDER_BY_NEW} pageSize={dynamicPageSize} infiniteScroll={defaultInfiniteScroll} - injectedItem={{ node: }} + injectedItem={ + !hasPremiumPlus && { + node: , + } + } meta={ showFilters && (
{}} className="wunderbar--inline"> diff --git a/ui/component/recommendedContent/index.js b/ui/component/recommendedContent/index.js index d807670a1..271f88bd9 100644 --- a/ui/component/recommendedContent/index.js +++ b/ui/component/recommendedContent/index.js @@ -15,7 +15,7 @@ const select = (state, props) => { recommendedContentUris, nextRecommendedUri, isSearching: selectIsSearching(state), - userHasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state), + hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state), }; }; diff --git a/ui/component/recommendedContent/view.jsx b/ui/component/recommendedContent/view.jsx index e54be2a0b..15a38b974 100644 --- a/ui/component/recommendedContent/view.jsx +++ b/ui/component/recommendedContent/view.jsx @@ -29,7 +29,7 @@ type Props = { claimId: string, metadata: any, location: UrlLocation, - userHasPremiumPlus: boolean, + hasPremiumPlus: boolean, }; export default React.memo(function RecommendedContent(props: Props) { @@ -41,11 +41,11 @@ export default React.memo(function RecommendedContent(props: Props) { isSearching, claim, location, - userHasPremiumPlus, + hasPremiumPlus, } = props; const claimId: ?string = claim && claim.claim_id; - const injectAds = SHOW_ADS && IS_WEB && !userHasPremiumPlus; + const injectAds = SHOW_ADS && IS_WEB && !hasPremiumPlus; function claimContainsBlockedWords(claim: ?StreamClaim) { if (BLOCKED_WORDS) { @@ -77,7 +77,7 @@ export default React.memo(function RecommendedContent(props: Props) { const { onRecsLoaded: onRecommendationsLoaded, onClickedRecommended: onRecommendationClicked } = RecSys; const InjectedAd = - injectAds && !blacklistTriggered + injectAds && !blacklistTriggered && !hasPremiumPlus ? { node: , index: isMobile ? 0 : 3, diff --git a/ui/page/discover/index.js b/ui/page/discover/index.js index 541130f2c..e843ec496 100644 --- a/ui/page/discover/index.js +++ b/ui/page/discover/index.js @@ -8,6 +8,7 @@ import { selectActiveLivestreams } from 'redux/selectors/livestream'; import { selectFollowedTags } from 'redux/selectors/tags'; import { doToggleTagFollowDesktop } from 'redux/actions/tags'; import { selectClientSetting, selectLanguage } from 'redux/selectors/settings'; +import { selectOdyseeMembershipIsPremiumPlus } from 'redux/selectors/user'; import DiscoverPage from './view'; const select = (state, props) => { @@ -23,6 +24,7 @@ const select = (state, props) => { activeLivestreams: selectActiveLivestreams(state), languageSetting: selectLanguage(state), searchInLanguage: selectClientSetting(state, SETTINGS.SEARCH_IN_LANGUAGE), + hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state), }; }; diff --git a/ui/page/discover/view.jsx b/ui/page/discover/view.jsx index f5cd06d82..9af1ecf83 100644 --- a/ui/page/discover/view.jsx +++ b/ui/page/discover/view.jsx @@ -35,6 +35,7 @@ type Props = { tileLayout: boolean, activeLivestreams: ?LivestreamInfo, doFetchActiveLivestreams: (orderBy: ?Array, lang: ?Array) => void, + hasPremiumPlus: boolean, }; function DiscoverPage(props: Props) { @@ -51,6 +52,7 @@ function DiscoverPage(props: Props) { activeLivestreams, doFetchActiveLivestreams, dynamicRouteProps, + hasPremiumPlus, } = props; const buttonRef = useRef(); @@ -221,7 +223,7 @@ function DiscoverPage(props: Props) { tags={tags} hiddenNsfwMessage={} repostedClaimId={repostedClaim ? repostedClaim.claim_id : null} - injectedItem={!isWildWest && { node: }} + injectedItem={!isWildWest && !hasPremiumPlus && { node: }} // TODO: find a better way to determine discover / wild west vs other modes release times // for now including && !tags so that releaseTime={releaseTime || undefined} diff --git a/ui/page/home/index.js b/ui/page/home/index.js index 064bea390..65c6e2e9c 100644 --- a/ui/page/home/index.js +++ b/ui/page/home/index.js @@ -4,7 +4,12 @@ import { doOpenModal } from 'redux/actions/app'; import { doFetchActiveLivestreams } from 'redux/actions/livestream'; import { selectActiveLivestreams, selectFetchingActiveLivestreams } from 'redux/selectors/livestream'; import { selectFollowedTags } from 'redux/selectors/tags'; -import { selectHasOdyseeMembership, selectHomepageFetched, selectUserVerifiedEmail } from 'redux/selectors/user'; +import { + selectOdyseeMembershipIsPremiumPlus, + selectHasOdyseeMembership, + selectHomepageFetched, + selectUserVerifiedEmail, +} from 'redux/selectors/user'; import { selectSubscriptions } from 'redux/selectors/subscriptions'; import { selectShowMatureContent, @@ -28,6 +33,7 @@ const select = (state) => ({ hideScheduledLivestreams: selectClientSetting(state, SETTINGS.HIDE_SCHEDULED_LIVESTREAMS), homepageOrder: selectClientSetting(state, SETTINGS.HOMEPAGE_ORDER), hasMembership: selectHasOdyseeMembership(state), + hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state), }); const perform = (dispatch) => ({ diff --git a/ui/page/home/view.jsx b/ui/page/home/view.jsx index 3907fdc06..908648be0 100644 --- a/ui/page/home/view.jsx +++ b/ui/page/home/view.jsx @@ -45,6 +45,7 @@ type Props = { homepageOrder: HomepageOrder, doOpenModal: (id: string, ?{}) => void, hasMembership: ?boolean, + hasPremiumPlus: boolean, }; function HomePage(props: Props) { @@ -63,6 +64,7 @@ function HomePage(props: Props) { homepageOrder, doOpenModal, hasMembership, + hasPremiumPlus, } = props; const showPersonalizedChannels = (authenticated || !IS_WEB) && subscribedChannels && subscribedChannels.length > 0; @@ -160,7 +162,7 @@ function HomePage(props: Props) { hasSource prefixUris={getLivestreamUris(activeLivestreams, options.channelIds)} pins={{ urls: pinUrls, claimIds: pinnedClaimIds }} - injectedItem={index === 0 && { node: }} + injectedItem={index === 0 && !hasPremiumPlus && { node: }} forceShowReposts={id !== 'FOLLOWING'} loading={id === 'FOLLOWING' ? fetchingActiveLivestreams : false} /> diff --git a/ui/page/search/index.js b/ui/page/search/index.js index 4a1792382..75f25ffde 100644 --- a/ui/page/search/index.js +++ b/ui/page/search/index.js @@ -9,11 +9,13 @@ import { } from 'redux/selectors/search'; import { selectShowMatureContent } from 'redux/selectors/settings'; import { getSearchQueryString } from 'util/query-params'; +import { selectOdyseeMembershipIsPremiumPlus } from 'redux/selectors/user'; import SearchPage from './view'; const select = (state, props) => { const showMature = selectShowMatureContent(state); const urlParams = new URLSearchParams(props.location.search); + const hasPremiumPlus = selectOdyseeMembershipIsPremiumPlus(state); let urlQuery = urlParams.get('q') || null; if (urlQuery) { @@ -36,6 +38,7 @@ const select = (state, props) => { isSearching: selectIsSearching(state), uris: uris, hasReachedMaxResultsLength: hasReachedMaxResultsLength, + hasPremiumPlus: hasPremiumPlus, }; }; diff --git a/ui/page/search/view.jsx b/ui/page/search/view.jsx index 4c6880cda..0263add66 100644 --- a/ui/page/search/view.jsx +++ b/ui/page/search/view.jsx @@ -20,10 +20,11 @@ type Props = { uris: Array, isAuthenticated: boolean, hasReachedMaxResultsLength: boolean, + hasPremiumPlus: boolean, }; export default function SearchPage(props: Props) { - const { urlQuery, searchOptions, search, uris, isSearching, hasReachedMaxResultsLength } = props; + const { urlQuery, searchOptions, search, uris, isSearching, hasReachedMaxResultsLength, hasPremiumPlus } = props; const { push } = useHistory(); const [from, setFrom] = React.useState(0); @@ -103,7 +104,7 @@ export default function SearchPage(props: Props) { onSearchOptionsChanged={resetPage} /> } - injectedItem={{ node: , index: 3 }} + injectedItem={!hasPremiumPlus && { node: , index: 3 }} />
{__('These search results are provided by Odysee.')}