Only fallback to Discover if Following is first pinned (#4146)

zio/stable
dan 2024-05-21 05:03:17 +01:00 committed by GitHub
parent d6625c29d1
commit b89e4ded2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 15 deletions

View File

@ -17,7 +17,6 @@ import {
import {HomeFeedAPI} from '#/lib/api/feed/home' import {HomeFeedAPI} from '#/lib/api/feed/home'
import {aggregateUserInterests} from '#/lib/api/feed/utils' import {aggregateUserInterests} from '#/lib/api/feed/utils'
import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped'
import {useGate} from '#/lib/statsig/statsig'
import {logger} from '#/logger' import {logger} from '#/logger'
import {STALE} from '#/state/queries' import {STALE} from '#/state/queries'
import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const' import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const'
@ -111,6 +110,11 @@ export function usePostFeedQuery(
const enabled = const enabled =
opts?.enabled !== false && Boolean(moderationOpts) && Boolean(preferences) opts?.enabled !== false && Boolean(moderationOpts) && Boolean(preferences)
const userInterests = aggregateUserInterests(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 {getAgent} = useAgent()
const lastRun = useRef<{ const lastRun = useRef<{
data: InfiniteData<FeedPageUnselected> data: InfiniteData<FeedPageUnselected>
@ -118,7 +122,6 @@ export function usePostFeedQuery(
result: InfiniteData<FeedPage> result: InfiniteData<FeedPage>
} | null>(null) } | null>(null)
const lastPageCountRef = useRef(0) const lastPageCountRef = useRef(0)
const gate = useGate()
// Make sure this doesn't invalidate unless really needed. // Make sure this doesn't invalidate unless really needed.
const selectArgs = React.useMemo( const selectArgs = React.useMemo(
@ -150,15 +153,11 @@ export function usePostFeedQuery(
feedDesc, feedDesc,
feedParams: params || {}, feedParams: params || {},
feedTuners, feedTuners,
userInterests, // Not in the query key because they don't change.
getAgent, getAgent,
useBaseFollowingFeed: gate( // Not in the query key because they don't change:
'reduced_onboarding_and_home_algo_v2', userInterests,
{ // Not in the query key. Reacting to it switching isn't important:
// If you're not already in this experiment, we don't want to expose you to it now. enableFollowingToDiscoverFallback,
dangerouslyDisableExposureLogging: true,
},
),
}), }),
cursor: undefined, cursor: undefined,
} }
@ -392,14 +391,14 @@ function createApi({
feedTuners, feedTuners,
userInterests, userInterests,
getAgent, getAgent,
useBaseFollowingFeed, enableFollowingToDiscoverFallback,
}: { }: {
feedDesc: FeedDescriptor feedDesc: FeedDescriptor
feedParams: FeedParams feedParams: FeedParams
feedTuners: FeedTunerFn[] feedTuners: FeedTunerFn[]
userInterests?: string userInterests?: string
getAgent: () => BskyAgent getAgent: () => BskyAgent
useBaseFollowingFeed: boolean enableFollowingToDiscoverFallback: boolean
}) { }) {
if (feedDesc === 'following') { if (feedDesc === 'following') {
if (feedParams.mergeFeedEnabled) { if (feedParams.mergeFeedEnabled) {
@ -410,10 +409,10 @@ function createApi({
userInterests, userInterests,
}) })
} else { } else {
if (useBaseFollowingFeed) { if (enableFollowingToDiscoverFallback) {
return new FollowingFeedAPI({getAgent})
} else {
return new HomeFeedAPI({getAgent, userInterests}) return new HomeFeedAPI({getAgent, userInterests})
} else {
return new FollowingFeedAPI({getAgent})
} }
} }
} else if (feedDesc.startsWith('author')) { } else if (feedDesc.startsWith('author')) {