From 6ee2e42f5564b0de658d83d823a77e7c8bff199a Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 3 Jul 2024 10:33:58 -0500 Subject: [PATCH] Randomize the feeds shown in interstitial --- src/components/FeedInterstitials.tsx | 7 +++++++ src/state/queries/feed.ts | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/FeedInterstitials.tsx b/src/components/FeedInterstitials.tsx index 00342b39f2..fef2bcc38f 100644 --- a/src/components/FeedInterstitials.tsx +++ b/src/components/FeedInterstitials.tsx @@ -230,8 +230,15 @@ export function SuggestedFeeds() { const numFeedsToDisplay = 3 const t = useTheme() const {_} = useLingui() + const [initialCursor] = React.useState(() => { + const min = 9880 + const max = 9999 + const range = max - min + return Math.floor(Math.random() * range) + min + '' + }) const {data, isLoading, error} = useGetPopularFeedsQuery({ limit: numFeedsToDisplay, + cursor: initialCursor, }) const navigation = useNavigation() const {gtMobile} = useBreakpoints() diff --git a/src/state/queries/feed.ts b/src/state/queries/feed.ts index 36555c1813..ef1c1e1039 100644 --- a/src/state/queries/feed.ts +++ b/src/state/queries/feed.ts @@ -193,7 +193,7 @@ export const KNOWN_AUTHED_ONLY_FEEDS = [ 'at://did:plc:vpkhqolt662uhesyj6nxm7ys/app.bsky.feed.generator/followpics', // the gram, by why ] -type GetPopularFeedsOptions = {limit?: number} +type GetPopularFeedsOptions = {limit?: number; cursor?: string} export function createGetPopularFeedsQueryKey( options?: GetPopularFeedsOptions, @@ -240,7 +240,7 @@ export function useGetPopularFeedsQuery(options?: GetPopularFeedsOptions) { return res.data }, - initialPageParam: undefined, + initialPageParam: options?.cursor, getNextPageParam: lastPage => lastPage.cursor, select: useCallback( (