Gate base following feed usage (#3994)

zio/stable
Eric Bailey 2024-05-13 16:54:03 -05:00 committed by GitHub
parent 5d92ac2ce3
commit 9980012021
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 1 deletions

View File

@ -14,8 +14,10 @@ import {
useInfiniteQuery, useInfiniteQuery,
} from '@tanstack/react-query' } from '@tanstack/react-query'
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'
@ -116,6 +118,7 @@ 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(
@ -149,6 +152,7 @@ export function usePostFeedQuery(
feedTuners, feedTuners,
userInterests, // Not in the query key because they don't change. userInterests, // Not in the query key because they don't change.
getAgent, getAgent,
useBaseFollowingFeed: gate('reduced_onboarding_and_home_algo'),
}), }),
cursor: undefined, cursor: undefined,
} }
@ -382,12 +386,14 @@ function createApi({
feedTuners, feedTuners,
userInterests, userInterests,
getAgent, getAgent,
useBaseFollowingFeed,
}: { }: {
feedDesc: FeedDescriptor feedDesc: FeedDescriptor
feedParams: FeedParams feedParams: FeedParams
feedTuners: FeedTunerFn[] feedTuners: FeedTunerFn[]
userInterests?: string userInterests?: string
getAgent: () => BskyAgent getAgent: () => BskyAgent
useBaseFollowingFeed: boolean
}) { }) {
if (feedDesc === 'following') { if (feedDesc === 'following') {
if (feedParams.mergeFeedEnabled) { if (feedParams.mergeFeedEnabled) {
@ -398,7 +404,11 @@ function createApi({
userInterests, userInterests,
}) })
} else { } else {
return new FollowingFeedAPI({getAgent}) if (useBaseFollowingFeed) {
return new FollowingFeedAPI({getAgent})
} else {
return new HomeFeedAPI({getAgent, userInterests})
}
} }
} else if (feedDesc.startsWith('author')) { } else if (feedDesc.startsWith('author')) {
const [_, actor, filter] = feedDesc.split('|') const [_, actor, filter] = feedDesc.split('|')