[Experiment] Suggest profiles in profile (#5030)

* Rename variable to disambiguate with parent scope

* More variables where they are used

* Inline variables

* Add suggestions in profile

* Gate it

* rm space

* Remove header suggestions under gate
This commit is contained in:
dan 2024-08-30 16:54:55 +01:00 committed by GitHub
parent 46b7193a2b
commit dbbbba1d32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 110 additions and 38 deletions

View file

@ -101,7 +101,7 @@ const feedInterstitialType = 'interstitialFeeds'
const followInterstitialType = 'interstitialFollows'
const progressGuideInterstitialType = 'interstitialProgressGuide'
const interstials: Record<
'following' | 'discover',
'following' | 'discover' | 'profile',
(FeedItem & {
type:
| 'interstitialFeeds'
@ -128,6 +128,16 @@ const interstials: Record<
slot: 20,
},
],
profile: [
{
type: followInterstitialType,
params: {
variant: 'default',
},
key: followInterstitialType,
slot: 5,
},
],
}
export function getFeedPostSlice(feedItem: FeedItem): FeedPostSlice | null {
@ -193,9 +203,7 @@ let Feed = ({
const [isPTRing, setIsPTRing] = React.useState(false)
const checkForNewRef = React.useRef<(() => void) | null>(null)
const lastFetchRef = React.useRef<number>(Date.now())
const [feedType, feedUri] = feed.split('|')
const feedIsDiscover = feedUri === DISCOVER_FEED_URI
const feedIsFollowing = feedType === 'following'
const [feedType, feedUri, feedTab] = feed.split('|')
const gate = useGate()
const opts = React.useMemo(
@ -339,14 +347,21 @@ let Feed = ({
}
if (hasSession) {
const feedType = feedIsFollowing
? 'following'
: feedIsDiscover
? 'discover'
: undefined
let feedKind: 'following' | 'discover' | 'profile' | undefined
if (feedType === 'following') {
feedKind = 'following'
} else if (feedUri === DISCOVER_FEED_URI) {
feedKind = 'discover'
} else if (
feedType === 'author' &&
(feedTab === 'posts_and_author_threads' ||
feedTab === 'posts_with_replies')
) {
feedKind = 'profile'
}
if (feedType) {
for (const interstitial of interstials[feedType]) {
if (feedKind) {
for (const interstitial of interstials[feedKind]) {
const shouldShow =
(interstitial.type === feedInterstitialType &&
gate('suggested_feeds_interstitial')) ||
@ -377,9 +392,9 @@ let Feed = ({
isEmpty,
lastFetchedAt,
data,
feedType,
feedUri,
feedIsDiscover,
feedIsFollowing,
feedTab,
gate,
hasSession,
])
@ -470,7 +485,7 @@ let Feed = ({
} else if (item.type === feedInterstitialType) {
return <SuggestedFeeds />
} else if (item.type === followInterstitialType) {
return <SuggestedFollows />
return <SuggestedFollows feed={feed} />
} else if (item.type === progressGuideInterstitialType) {
return <ProgressGuide />
} else if (item.type === 'slice') {