@@ -19,6 +19,7 @@ type Props = {
19
19
discussionApiUrl : string ;
20
20
absoluteServerTimes : boolean ;
21
21
renderingTarget : RenderingTarget ;
22
+ isAdFreeUser : boolean ;
22
23
} ;
23
24
24
25
type OnwardsResponse = {
@@ -32,6 +33,20 @@ const minHeight = css`
32
33
min-height : 300px ;
33
34
` ;
34
35
36
+ const isTrailPaidContent = ( trailType : FETrailType ) =>
37
+ trailType . branding ?. brandingType ?. name === 'paid-content' ;
38
+
39
+ const buildTrails = (
40
+ trails : FETrailType [ ] ,
41
+ trailLimit : number ,
42
+ isAdFreeUser : boolean ,
43
+ ) : TrailType [ ] => {
44
+ return trails
45
+ . filter ( ( trailType ) => ! ( isTrailPaidContent ( trailType ) && isAdFreeUser ) )
46
+ . slice ( 0 , trailLimit )
47
+ . map ( decideTrail ) ;
48
+ } ;
49
+
35
50
export const FetchOnwardsData = ( {
36
51
url,
37
52
limit,
@@ -40,16 +55,10 @@ export const FetchOnwardsData = ({
40
55
discussionApiUrl,
41
56
absoluteServerTimes,
42
57
renderingTarget,
58
+ isAdFreeUser,
43
59
} : Props ) => {
44
60
const { data, error } = useApi < OnwardsResponse > ( url ) ;
45
61
46
- const buildTrails = (
47
- trails : FETrailType [ ] ,
48
- trailLimit : number ,
49
- ) : TrailType [ ] => {
50
- return trails . slice ( 0 , trailLimit ) . map ( decideTrail ) ;
51
- } ;
52
-
53
62
if ( error ) {
54
63
// Send the error to Sentry and then prevent the element from rendering
55
64
window . guardian . modules . sentry . reportError ( error , 'onwards-lower' ) ;
@@ -76,7 +85,7 @@ export const FetchOnwardsData = ({
76
85
< div css = { minHeight } >
77
86
< Carousel
78
87
heading = { data . heading || data . displayname } // Sometimes the api returns heading as 'displayName'
79
- trails = { buildTrails ( data . trails , limit ) }
88
+ trails = { buildTrails ( data . trails , limit , isAdFreeUser ) }
80
89
description = { data . description }
81
90
onwardsSource = { onwardsSource }
82
91
format = { format }
0 commit comments