@@ -16,7 +16,7 @@ import {useQueryClient} from '@tanstack/react-query'
16
16
17
17
import { DISCOVER_FEED_URI , KNOWN_SHUTDOWN_FEEDS } from '#/lib/constants'
18
18
import { useInitialNumToRender } from '#/lib/hooks/useInitialNumToRender'
19
- import { logEvent , useGate } from '#/lib/statsig/statsig'
19
+ import { logEvent } from '#/lib/statsig/statsig'
20
20
import { useTheme } from '#/lib/ThemeContext'
21
21
import { logger } from '#/logger'
22
22
import { isIOS , isWeb } from '#/platform/detection'
@@ -32,11 +32,7 @@ import {
32
32
usePostFeedQuery ,
33
33
} from '#/state/queries/post-feed'
34
34
import { useSession } from '#/state/session'
35
- import {
36
- ProgressGuide ,
37
- SuggestedFeeds ,
38
- SuggestedFollows ,
39
- } from '#/components/FeedInterstitials'
35
+ import { ProgressGuide , SuggestedFollows } from '#/components/FeedInterstitials'
40
36
import { List , ListRef } from '../util/List'
41
37
import { PostFeedLoadingPlaceholder } from '../util/LoadingPlaceholder'
42
38
import { LoadMoreRetryBtn } from '../util/LoadMoreRetryBtn'
@@ -84,74 +80,15 @@ type FeedRow =
84
80
key : string
85
81
uri : string
86
82
}
87
- | {
88
- type : 'interstitialFeeds'
89
- key : string
90
- params : {
91
- variant : 'default' | string
92
- }
93
- slot : number
94
- }
95
83
| {
96
84
type : 'interstitialFollows'
97
85
key : string
98
- params : {
99
- variant : 'default' | string
100
- }
101
- slot : number
102
86
}
103
87
| {
104
88
type : 'interstitialProgressGuide'
105
89
key : string
106
- params : {
107
- variant : 'default' | string
108
- }
109
- slot : number
110
90
}
111
91
112
- const feedInterstitialType = 'interstitialFeeds'
113
- const followInterstitialType = 'interstitialFollows'
114
- const progressGuideInterstitialType = 'interstitialProgressGuide'
115
- const interstials : Record <
116
- 'following' | 'discover' | 'profile' ,
117
- ( FeedRow & {
118
- type :
119
- | 'interstitialFeeds'
120
- | 'interstitialFollows'
121
- | 'interstitialProgressGuide'
122
- } ) [ ]
123
- > = {
124
- following : [ ] ,
125
- discover : [
126
- {
127
- type : progressGuideInterstitialType ,
128
- params : {
129
- variant : 'default' ,
130
- } ,
131
- key : progressGuideInterstitialType ,
132
- slot : 0 ,
133
- } ,
134
- {
135
- type : followInterstitialType ,
136
- params : {
137
- variant : 'default' ,
138
- } ,
139
- key : followInterstitialType ,
140
- slot : 20 ,
141
- } ,
142
- ] ,
143
- profile : [
144
- {
145
- type : followInterstitialType ,
146
- params : {
147
- variant : 'default' ,
148
- } ,
149
- key : followInterstitialType ,
150
- slot : 5 ,
151
- } ,
152
- ] ,
153
- }
154
-
155
92
export function getFeedPostSlice ( feedRow : FeedRow ) : FeedPostSlice | null {
156
93
if ( feedRow . type === 'sliceItem' ) {
157
94
return feedRow . slice
@@ -217,7 +154,6 @@ let Feed = ({
217
154
const checkForNewRef = React . useRef < ( ( ) => void ) | null > ( null )
218
155
const lastFetchRef = React . useRef < number > ( Date . now ( ) )
219
156
const [ feedType , feedUri , feedTab ] = feed . split ( '|' )
220
- const gate = useGate ( )
221
157
222
158
const opts = React . useMemo (
223
159
( ) => ( { enabled, ignoreFilterFor} ) ,
@@ -317,6 +253,19 @@ let Feed = ({
317
253
} , [ pollInterval ] )
318
254
319
255
const feedItems : FeedRow [ ] = React . useMemo ( ( ) => {
256
+ let feedKind : 'following' | 'discover' | 'profile' | undefined
257
+ if ( feedType === 'following' ) {
258
+ feedKind = 'following'
259
+ } else if ( feedUri === DISCOVER_FEED_URI ) {
260
+ feedKind = 'discover'
261
+ } else if (
262
+ feedType === 'author' &&
263
+ ( feedTab === 'posts_and_author_threads' ||
264
+ feedTab === 'posts_with_replies' )
265
+ ) {
266
+ feedKind = 'profile'
267
+ }
268
+
320
269
let arr : FeedRow [ ] = [ ]
321
270
if ( KNOWN_SHUTDOWN_FEEDS . includes ( feedUri ) ) {
322
271
arr . push ( {
@@ -336,8 +285,34 @@ let Feed = ({
336
285
key : 'empty' ,
337
286
} )
338
287
} else if ( data ) {
288
+ let sliceIndex = - 1
339
289
for ( const page of data ?. pages ) {
340
290
for ( const slice of page . slices ) {
291
+ sliceIndex ++
292
+
293
+ if ( hasSession ) {
294
+ if ( feedKind === 'discover' ) {
295
+ if ( sliceIndex === 0 ) {
296
+ arr . push ( {
297
+ type : 'interstitialProgressGuide' ,
298
+ key : 'interstitial-' + sliceIndex + '-' + lastFetchedAt ,
299
+ } )
300
+ } else if ( sliceIndex === 20 ) {
301
+ arr . push ( {
302
+ type : 'interstitialFollows' ,
303
+ key : 'interstitial-' + sliceIndex + '-' + lastFetchedAt ,
304
+ } )
305
+ }
306
+ } else if ( feedKind === 'profile' ) {
307
+ if ( sliceIndex === 5 ) {
308
+ arr . push ( {
309
+ type : 'interstitialFollows' ,
310
+ key : 'interstitial-' + sliceIndex + '-' + lastFetchedAt ,
311
+ } )
312
+ }
313
+ }
314
+ }
315
+
341
316
if ( slice . isIncompleteThread && slice . items . length >= 3 ) {
342
317
const beforeLast = slice . items . length - 2
343
318
const last = slice . items . length - 1
@@ -396,45 +371,6 @@ let Feed = ({
396
371
} )
397
372
}
398
373
399
- if ( hasSession ) {
400
- let feedKind : 'following' | 'discover' | 'profile' | undefined
401
- if ( feedType === 'following' ) {
402
- feedKind = 'following'
403
- } else if ( feedUri === DISCOVER_FEED_URI ) {
404
- feedKind = 'discover'
405
- } else if (
406
- feedType === 'author' &&
407
- ( feedTab === 'posts_and_author_threads' ||
408
- feedTab === 'posts_with_replies' )
409
- ) {
410
- feedKind = 'profile'
411
- }
412
-
413
- if ( feedKind ) {
414
- for ( const interstitial of interstials [ feedKind ] ) {
415
- const shouldShow =
416
- ( interstitial . type === feedInterstitialType &&
417
- gate ( 'suggested_feeds_interstitial' ) ) ||
418
- interstitial . type === followInterstitialType ||
419
- interstitial . type === progressGuideInterstitialType
420
-
421
- if ( shouldShow ) {
422
- const variant = 'default' // replace with experiment variant
423
- const int = {
424
- ...interstitial ,
425
- params : { variant} ,
426
- // overwrite key with unique value
427
- key : [ interstitial . type , variant , lastFetchedAt ] . join ( ':' ) ,
428
- }
429
-
430
- if ( arr . length > interstitial . slot ) {
431
- arr . splice ( interstitial . slot , 0 , int )
432
- }
433
- }
434
- }
435
- }
436
- }
437
-
438
374
return arr
439
375
} , [
440
376
isFetched ,
@@ -445,7 +381,6 @@ let Feed = ({
445
381
feedType ,
446
382
feedUri ,
447
383
feedTab ,
448
- gate ,
449
384
hasSession ,
450
385
] )
451
386
@@ -529,11 +464,9 @@ let Feed = ({
529
464
return < PostFeedLoadingPlaceholder />
530
465
} else if ( row . type === 'feedShutdownMsg' ) {
531
466
return < FeedShutdownMsg feedUri = { feedUri } />
532
- } else if ( row . type === feedInterstitialType ) {
533
- return < SuggestedFeeds />
534
- } else if ( row . type === followInterstitialType ) {
467
+ } else if ( row . type === 'interstitialFollows' ) {
535
468
return < SuggestedFollows feed = { feed } />
536
- } else if ( row . type === progressGuideInterstitialType ) {
469
+ } else if ( row . type === 'interstitialProgressGuide' ) {
537
470
return < ProgressGuide />
538
471
} else if ( row . type === 'sliceItem' ) {
539
472
const slice = row . slice
0 commit comments