Age Assurance V2 (#9479)
* Age Assurance V2 * Tighten up test * Add todos for sdk migration * Align RQ versions * Use useEffect for side effect * Improve effects, memoize * Standarize on birthdate * Copy feedback * Copilot * Add support link * Reove double .. * Cleanup * Remove redirect dialog * Cleanup todos, add comments * Update splash in main template too * Mock some stuff * Exhaustive checks Co-authored-by: Samuel Newman <mozzius@protonmail.com> * Exhaustive checks Co-authored-by: Samuel Newman <mozzius@protonmail.com> * Small fix to bday handling * Add comment * onboarding style tweak sneaking this in sorry! * rm unreachable breaks * Put useIntentHandler back on web * Remove misleading success set * Align on birthdate --------- Co-authored-by: Samuel Newman <mozzius@protonmail.com>
This commit is contained in:
@@ -31,7 +31,6 @@ import {aggregateUserInterests} from '#/lib/api/feed/utils'
|
||||
import {FeedTuner, type FeedTunerFn} from '#/lib/api/feed-manip'
|
||||
import {DISCOVER_FEED_URI} from '#/lib/constants'
|
||||
import {logger} from '#/logger'
|
||||
import {useAgeAssuranceContext} from '#/state/ageAssurance'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const'
|
||||
import {useAgent} from '#/state/session'
|
||||
@@ -141,12 +140,8 @@ export function usePostFeedQuery(
|
||||
* available for the remainder of the session, so this delay only affects cold
|
||||
* loads. -esb
|
||||
*/
|
||||
const {isReady: isAgeAssuranceReady} = useAgeAssuranceContext()
|
||||
const enabled =
|
||||
opts?.enabled !== false &&
|
||||
Boolean(moderationOpts) &&
|
||||
Boolean(preferences) &&
|
||||
isAgeAssuranceReady
|
||||
opts?.enabled !== false && Boolean(moderationOpts) && Boolean(preferences)
|
||||
const userInterests = aggregateUserInterests(preferences)
|
||||
const followingPinnedIndex =
|
||||
preferences?.savedFeeds?.findIndex(
|
||||
|
||||
@@ -26,6 +26,7 @@ export function usePostQuery(uri: string | undefined) {
|
||||
const res = await agent.resolveHandle({
|
||||
handle: urip.host,
|
||||
})
|
||||
// @ts-expect-error TODO new-sdk-migration
|
||||
urip.host = res.data.did
|
||||
}
|
||||
|
||||
@@ -54,6 +55,7 @@ export function useGetPost() {
|
||||
const res = await agent.resolveHandle({
|
||||
handle: urip.host,
|
||||
})
|
||||
// @ts-expect-error TODO new-sdk-migration
|
||||
urip.host = res.data.did
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ export async function getPostgateRecord({
|
||||
const res = await agent.resolveHandle({
|
||||
handle: urip.host,
|
||||
})
|
||||
// @ts-expect-error TODO new-sdk-migration
|
||||
urip.host = res.data.did
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +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/ageAssurance'
|
||||
import {makeAgeRestrictedModerationPrefs} from '#/state/ageAssurance/const'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {
|
||||
DEFAULT_HOME_FEED_PREFS,
|
||||
@@ -24,6 +22,7 @@ import {
|
||||
} from '#/state/queries/preferences/types'
|
||||
import {useAgent} from '#/state/session'
|
||||
import {saveLabelers} from '#/state/session/agent-config'
|
||||
import {useAgeAssurance} from '#/ageAssurance'
|
||||
|
||||
export * from '#/state/queries/preferences/const'
|
||||
export * from '#/state/queries/preferences/moderation'
|
||||
@@ -34,7 +33,7 @@ export const preferencesQueryKey = [preferencesQueryKeyRoot]
|
||||
|
||||
export function usePreferencesQuery() {
|
||||
const agent = useAgent()
|
||||
const {isAgeRestricted} = useAgeAssuranceContext()
|
||||
const aa = useAgeAssurance()
|
||||
|
||||
return useQuery({
|
||||
staleTime: STALE.SECONDS.FIFTEEN,
|
||||
@@ -75,18 +74,19 @@ export function usePreferencesQuery() {
|
||||
},
|
||||
select: useCallback(
|
||||
(data: UsePreferencesQueryResponse) => {
|
||||
const isUnderage = (data.userAge || 0) < 18
|
||||
if (isUnderage || isAgeRestricted) {
|
||||
/**
|
||||
* Prefs are all downstream of age assurance now. For logged-out
|
||||
* users, we override moderation prefs based on AA state.
|
||||
*/
|
||||
if (aa.state.access !== aa.Access.Full) {
|
||||
data = {
|
||||
...data,
|
||||
moderationPrefs: makeAgeRestrictedModerationPrefs(
|
||||
data.moderationPrefs,
|
||||
),
|
||||
moderationPrefs: DEFAULT_LOGGED_OUT_PREFERENCES.moderationPrefs,
|
||||
}
|
||||
}
|
||||
return data
|
||||
},
|
||||
[isAgeRestricted],
|
||||
[aa],
|
||||
),
|
||||
})
|
||||
}
|
||||
@@ -168,21 +168,6 @@ export function usePreferencesSetAdultContentMutation() {
|
||||
})
|
||||
}
|
||||
|
||||
export function usePreferencesSetBirthDateMutation() {
|
||||
const queryClient = useQueryClient()
|
||||
const agent = useAgent()
|
||||
|
||||
return useMutation<void, unknown, {birthDate: Date}>({
|
||||
mutationFn: async ({birthDate}: {birthDate: Date}) => {
|
||||
await agent.setPersonalDetails({birthDate: birthDate.toISOString()})
|
||||
// triggers a refetch
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: preferencesQueryKey,
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useSetFeedViewPreferencesMutation() {
|
||||
const queryClient = useQueryClient()
|
||||
const agent = useAgent()
|
||||
|
||||
@@ -17,6 +17,7 @@ export function useResolveUriQuery(uri: string | undefined): UriUseQueryResult {
|
||||
const urip = new AtUri(uri || '')
|
||||
const res = useResolveDidQuery(urip.host)
|
||||
if (res.data) {
|
||||
// @ts-expect-error TODO new-sdk-migration
|
||||
urip.host = res.data
|
||||
return {
|
||||
...res,
|
||||
|
||||
@@ -97,6 +97,7 @@ export async function getThreadgateRecord({
|
||||
const res = await agent.resolveHandle({
|
||||
handle: urip.host,
|
||||
})
|
||||
// @ts-expect-error TODO new-sdk-migration
|
||||
urip.host = res.data.did
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user