Delay post-feed queries instead
This commit is contained in:
@@ -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,
|
||||
// }))(),
|
||||
// )
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user