···2828import {DISCOVER_FEED_URI} from '#/lib/constants'
2929import {BSKY_FEED_OWNER_DIDS} from '#/lib/constants'
3030import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped'
3131+import {useGate} from '#/lib/statsig/statsig'
3132import {logger} from '#/logger'
3233import {STALE} from '#/state/queries'
3334import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const'
···109110 fetchedAt: number
110111}
111112112112-const PAGE_SIZE = 30
113113+/**
114114+ * The minimum number of posts we want in a single "page" of results. Since we
115115+ * filter out unwanted content, we may fetch more than this number to ensure
116116+ * that we get _at least_ this number.
117117+ */
118118+const MIN_POSTS = 30
113119114120export function usePostFeedQuery(
115121 feedDesc: FeedDescriptor,
116122 params?: FeedParams,
117123 opts?: {enabled?: boolean; ignoreFilterFor?: string},
118124) {
125125+ const gate = useGate()
119126 const feedTuners = useFeedTuners(feedDesc)
120127 const moderationOpts = useModerationOpts()
121128 const {data: preferences} = usePreferencesQuery()
···134141 result: InfiniteData<FeedPage>
135142 } | null>(null)
136143 const isDiscover = feedDesc.includes(DISCOVER_FEED_URI)
144144+145145+ /**
146146+ * The number of posts to fetch in a single request. Because we filter
147147+ * unwanted content, we may over-fetch here to try and fill pages by
148148+ * `MIN_POSTS`.
149149+ */
150150+ const fetchLimit = gate('post_feed_lang_window') ? 100 : MIN_POSTS
137151138152 // Make sure this doesn't invalidate unless really needed.
139153 const selectArgs = React.useMemo(
···175189 }
176190177191 try {
178178- const res = await api.fetch({cursor, limit: PAGE_SIZE})
192192+ const res = await api.fetch({cursor, limit: fetchLimit})
179193180194 /*
181195 * If this is a public view, we need to check if posts fail moderation.
···373387 // Now track how many items we really want, and fetch more if needed.
374388 if (isLoading || isRefetching) {
375389 // During the initial fetch, we want to get an entire page's worth of items.
376376- wantedItemCount.current = PAGE_SIZE
390390+ wantedItemCount.current = MIN_POSTS
377391 } else if (isFetchingNextPage) {
378392 if (itemCount > wantedItemCount.current) {
379393 // We have more items than wantedItemCount, so wantedItemCount must be out of date.
380394 // Some other code must have called fetchNextPage(), for example, from onEndReached.
381395 // Adjust the wantedItemCount to reflect that we want one more full page of items.
382382- wantedItemCount.current = itemCount + PAGE_SIZE
396396+ wantedItemCount.current = itemCount + MIN_POSTS
383397 }
384398 } else if (hasNextPage) {
385399 // At this point we're not fetching anymore, so it's time to make a decision.