Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add gate to increase post-feed page size (#5473)

* Add gate to increase post-feed page size

* Exclude Discover

* Remove exception

* Clarify intent

* Let gate cache

authored by

Eric Bailey and committed by
GitHub
224ff42c be3c6ab9

+21 -5
+3 -1
src/lib/statsig/gates.ts
··· 1 1 export type Gate = 2 2 // Keep this alphabetic please. 3 - 'debug_show_feedcontext' | 'suggested_feeds_interstitial' 3 + | 'debug_show_feedcontext' 4 + | 'post_feed_lang_window' 5 + | 'suggested_feeds_interstitial'
+18 -4
src/state/queries/post-feed.ts
··· 28 28 import {DISCOVER_FEED_URI} from '#/lib/constants' 29 29 import {BSKY_FEED_OWNER_DIDS} from '#/lib/constants' 30 30 import {moderatePost_wrapped as moderatePost} from '#/lib/moderatePost_wrapped' 31 + import {useGate} from '#/lib/statsig/statsig' 31 32 import {logger} from '#/logger' 32 33 import {STALE} from '#/state/queries' 33 34 import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const' ··· 109 110 fetchedAt: number 110 111 } 111 112 112 - const PAGE_SIZE = 30 113 + /** 114 + * The minimum number of posts we want in a single "page" of results. Since we 115 + * filter out unwanted content, we may fetch more than this number to ensure 116 + * that we get _at least_ this number. 117 + */ 118 + const MIN_POSTS = 30 113 119 114 120 export function usePostFeedQuery( 115 121 feedDesc: FeedDescriptor, 116 122 params?: FeedParams, 117 123 opts?: {enabled?: boolean; ignoreFilterFor?: string}, 118 124 ) { 125 + const gate = useGate() 119 126 const feedTuners = useFeedTuners(feedDesc) 120 127 const moderationOpts = useModerationOpts() 121 128 const {data: preferences} = usePreferencesQuery() ··· 134 141 result: InfiniteData<FeedPage> 135 142 } | null>(null) 136 143 const isDiscover = feedDesc.includes(DISCOVER_FEED_URI) 144 + 145 + /** 146 + * The number of posts to fetch in a single request. Because we filter 147 + * unwanted content, we may over-fetch here to try and fill pages by 148 + * `MIN_POSTS`. 149 + */ 150 + const fetchLimit = gate('post_feed_lang_window') ? 100 : MIN_POSTS 137 151 138 152 // Make sure this doesn't invalidate unless really needed. 139 153 const selectArgs = React.useMemo( ··· 175 189 } 176 190 177 191 try { 178 - const res = await api.fetch({cursor, limit: PAGE_SIZE}) 192 + const res = await api.fetch({cursor, limit: fetchLimit}) 179 193 180 194 /* 181 195 * If this is a public view, we need to check if posts fail moderation. ··· 373 387 // Now track how many items we really want, and fetch more if needed. 374 388 if (isLoading || isRefetching) { 375 389 // During the initial fetch, we want to get an entire page's worth of items. 376 - wantedItemCount.current = PAGE_SIZE 390 + wantedItemCount.current = MIN_POSTS 377 391 } else if (isFetchingNextPage) { 378 392 if (itemCount > wantedItemCount.current) { 379 393 // We have more items than wantedItemCount, so wantedItemCount must be out of date. 380 394 // Some other code must have called fetchNextPage(), for example, from onEndReached. 381 395 // Adjust the wantedItemCount to reflect that we want one more full page of items. 382 - wantedItemCount.current = itemCount + PAGE_SIZE 396 + wantedItemCount.current = itemCount + MIN_POSTS 383 397 } 384 398 } else if (hasNextPage) { 385 399 // At this point we're not fetching anymore, so it's time to make a decision.