From b89e4ded2faf064ceed63bdf3e0c3d0124903b12 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 21 May 2024 05:03:17 +0100 Subject: [PATCH] Only fallback to Discover if Following is first pinned (#4146) --- src/state/queries/post-feed.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/state/queries/post-feed.ts b/src/state/queries/post-feed.ts index b763f28a..18c4b65a 100644 --- a/src/state/queries/post-feed.ts +++ b/src/state/queries/post-feed.ts @@ -17,7 +17,6 @@ import { import {HomeFeedAPI} from '#/lib/api/feed/home' import {aggregateUserInterests} from '#/lib/api/feed/utils' import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' -import {useGate} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {STALE} from '#/state/queries' import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const' @@ -111,6 +110,11 @@ export function usePostFeedQuery( const enabled = opts?.enabled !== false && Boolean(moderationOpts) && Boolean(preferences) const userInterests = aggregateUserInterests(preferences) + const followingPinnedIndex = + preferences?.savedFeeds?.findIndex( + f => f.pinned && f.value === 'following', + ) ?? -1 + const enableFollowingToDiscoverFallback = followingPinnedIndex === 0 const {getAgent} = useAgent() const lastRun = useRef<{ data: InfiniteData @@ -118,7 +122,6 @@ export function usePostFeedQuery( result: InfiniteData } | null>(null) const lastPageCountRef = useRef(0) - const gate = useGate() // Make sure this doesn't invalidate unless really needed. const selectArgs = React.useMemo( @@ -150,15 +153,11 @@ export function usePostFeedQuery( feedDesc, feedParams: params || {}, feedTuners, - userInterests, // Not in the query key because they don't change. getAgent, - useBaseFollowingFeed: gate( - 'reduced_onboarding_and_home_algo_v2', - { - // If you're not already in this experiment, we don't want to expose you to it now. - dangerouslyDisableExposureLogging: true, - }, - ), + // Not in the query key because they don't change: + userInterests, + // Not in the query key. Reacting to it switching isn't important: + enableFollowingToDiscoverFallback, }), cursor: undefined, } @@ -392,14 +391,14 @@ function createApi({ feedTuners, userInterests, getAgent, - useBaseFollowingFeed, + enableFollowingToDiscoverFallback, }: { feedDesc: FeedDescriptor feedParams: FeedParams feedTuners: FeedTunerFn[] userInterests?: string getAgent: () => BskyAgent - useBaseFollowingFeed: boolean + enableFollowingToDiscoverFallback: boolean }) { if (feedDesc === 'following') { if (feedParams.mergeFeedEnabled) { @@ -410,10 +409,10 @@ function createApi({ userInterests, }) } else { - if (useBaseFollowingFeed) { - return new FollowingFeedAPI({getAgent}) - } else { + if (enableFollowingToDiscoverFallback) { return new HomeFeedAPI({getAgent, userInterests}) + } else { + return new FollowingFeedAPI({getAgent}) } } } else if (feedDesc.startsWith('author')) {