From 6ecbc8198ccd841ec05d4841514bbbeeaa63d629 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 15 Jul 2025 12:41:30 -0500 Subject: [PATCH] Delay post-feed queries instead --- src/state/age-assurance/index.tsx | 4 ++-- src/state/queries/post-feed.ts | 10 +++++++++- src/state/queries/preferences/index.ts | 6 ------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/state/age-assurance/index.tsx b/src/state/age-assurance/index.tsx index faeea32f2c..9e6db44396 100644 --- a/src/state/age-assurance/index.tsx +++ b/src/state/age-assurance/index.tsx @@ -64,8 +64,8 @@ export function Provider({children}: {children: React.ReactNode}) { // 1e3, // (() => ({ // data: { - // lastInitiatedAt: new Date().toISOString(), - // status: 'pending', + // lastInitiatedAt: undefined,//new Date().toISOString(), + // status: 'unknown', // } as AppBskyUnspeccedDefs.AgeAssuranceState, // }))(), // ) diff --git a/src/state/queries/post-feed.ts b/src/state/queries/post-feed.ts index 583b0432b1..5f2ac9f4c5 100644 --- a/src/state/queries/post-feed.ts +++ b/src/state/queries/post-feed.ts @@ -32,6 +32,7 @@ import {FeedTuner, type FeedTunerFn} from '#/lib/api/feed-manip' import {DISCOVER_FEED_URI} from '#/lib/constants' import {BSKY_FEED_OWNER_DIDS} from '#/lib/constants' import {logger} from '#/logger' +import {useAgeAssuranceContext} from '#/state/age-assurance' import {STALE} from '#/state/queries' import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const' import {useAgent} from '#/state/session' @@ -135,8 +136,15 @@ export function usePostFeedQuery( const feedTuners = useFeedTuners(feedDesc) const moderationOpts = useModerationOpts() const {data: preferences} = usePreferencesQuery() + /** + * Load bearing: we need to await AA state or risk FOUC. + */ + const {isLoaded: isAALoaded} = useAgeAssuranceContext() const enabled = - opts?.enabled !== false && Boolean(moderationOpts) && Boolean(preferences) + opts?.enabled !== false && + Boolean(moderationOpts) && + Boolean(preferences) && + isAALoaded const userInterests = aggregateUserInterests(preferences) const followingPinnedIndex = preferences?.savedFeeds?.findIndex( diff --git a/src/state/queries/preferences/index.ts b/src/state/queries/preferences/index.ts index b21809fd70..fa1f734c41 100644 --- a/src/state/queries/preferences/index.ts +++ b/src/state/queries/preferences/index.ts @@ -10,7 +10,6 @@ import {PROD_DEFAULT_FEED} from '#/lib/constants' import {replaceEqualDeep} from '#/lib/functions' import {getAge} from '#/lib/strings/time' import {logger} from '#/logger' -import {useAgeAssuranceContext} from '#/state/age-assurance' import {useMaybeApplyAgeRestrictedModerationPrefs} from '#/state/age-assurance/useMaybeApplyAgeRestrictedModerationPrefs' import {STALE} from '#/state/queries' import { @@ -34,14 +33,9 @@ export const preferencesQueryKey = [preferencesQueryKeyRoot] export function usePreferencesQuery() { const agent = useAgent() - const {isLoaded: isAAStateLoaded} = useAgeAssuranceContext() const maybeOverrideModPrefs = useMaybeApplyAgeRestrictedModerationPrefs() return useQuery({ - /* - * We must await AA state, otherwise users may see a FOUC - esb - */ - enabled: isAAStateLoaded, staleTime: STALE.SECONDS.FIFTEEN, structuralSharing: replaceEqualDeep, refetchOnWindowFocus: true,