Make Category & Channel pages re-fill ads after scrolling every 2 pages

This commit is contained in:
infinite-persistence 2022-04-18 19:05:27 +08:00
parent 327a574982
commit 4ae3fe7ea0
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 19 additions and 2 deletions

View file

@ -166,7 +166,13 @@ function ChannelContent(props: Props) {
infiniteScroll={defaultInfiniteScroll} infiniteScroll={defaultInfiniteScroll}
injectedItem={ injectedItem={
!hasPremiumPlus && { !hasPremiumPlus && {
node: <Ads small type="video" tileLayout />, node: (index, lastVisibleIndex, pageSize) => {
if (pageSize && index < pageSize) {
return index === lastVisibleIndex ? <Ads type="video" tileLayout={tileLayout} small /> : null;
} else {
return index % (pageSize * 2) === 0 ? <Ads type="video" tileLayout={tileLayout} small /> : null;
}
},
} }
} }
meta={ meta={

View file

@ -223,7 +223,18 @@ function DiscoverPage(props: Props) {
tags={tags} tags={tags}
hiddenNsfwMessage={<HiddenNsfw type="page" />} hiddenNsfwMessage={<HiddenNsfw type="page" />}
repostedClaimId={repostedClaim ? repostedClaim.claim_id : null} repostedClaimId={repostedClaim ? repostedClaim.claim_id : null}
injectedItem={!isWildWest && !hasPremiumPlus && { node: <Ads small type="video" tileLayout /> }} injectedItem={
!isWildWest &&
!hasPremiumPlus && {
node: (index, lastVisibleIndex, pageSize) => {
if (pageSize && index < pageSize) {
return index === lastVisibleIndex ? <Ads small type="video" tileLayout={tileLayout} /> : null;
} else {
return index % (pageSize * 2) === 0 ? <Ads small type="video" tileLayout={tileLayout} /> : null;
}
},
}
}
// TODO: find a better way to determine discover / wild west vs other modes release times // TODO: find a better way to determine discover / wild west vs other modes release times
// for now including && !tags so that // for now including && !tags so that
releaseTime={releaseTime || undefined} releaseTime={releaseTime || undefined}