Standarize on birthdate

This commit is contained in:
Eric Bailey
2025-12-04 10:12:08 -06:00
parent 1e01b28f54
commit 3b8c5e9699
6 changed files with 33 additions and 32 deletions
+15 -15
View File
@@ -8,7 +8,7 @@ import {dateDiff, useGetTimeAgo} from '#/lib/hooks/useTimeAgo'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isWeb} from '#/platform/detection' import {isWeb} from '#/platform/detection'
import {isNative} from '#/platform/detection' import {isNative} from '#/platform/detection'
import {useIsBirthDateUpdateAllowed} from '#/state/birthDate' import {useIsBirthdateUpdateAllowed} from '#/state/birthdate'
import {useSessionApi} from '#/state/session' import {useSessionApi} from '#/state/session'
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf' import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
import {Admonition} from '#/components/Admonition' import {Admonition} from '#/components/Admonition'
@@ -42,10 +42,10 @@ export function NoAccessScreen() {
const {_} = useLingui() const {_} = useLingui()
const {gtPhone} = useBreakpoints() const {gtPhone} = useBreakpoints()
const insets = useSafeAreaInsets() const insets = useSafeAreaInsets()
const birthdayControl = useDialogControl() const birthdateControl = useDialogControl()
const {data} = useAgeAssuranceDataContext() const {data} = useAgeAssuranceDataContext()
const region = useAgeAssuranceRegionConfig() const region = useAgeAssuranceRegionConfig()
const isBirthdateUpdateAllowed = useIsBirthDateUpdateAllowed() const isBirthdateUpdateAllowed = useIsBirthdateUpdateAllowed()
const {logoutCurrentAccount} = useSessionApi() const {logoutCurrentAccount} = useSessionApi()
const isAARegion = !!region const isAARegion = !!region
@@ -78,15 +78,15 @@ export function NoAccessScreen() {
logoutCurrentAccount('AgeAssuranceNoAccessScreen') logoutCurrentAccount('AgeAssuranceNoAccessScreen')
}, [logoutCurrentAccount]) }, [logoutCurrentAccount])
const birthdayUpdateText = canUpdateBirthday ? ( const birthdateUpdateText = canUpdateBirthday ? (
<Text style={[textStyles]}> <Text style={[textStyles]}>
<Trans> <Trans>
If your birth date is not accurate, you can update it by{' '} If your birthdate is not accurate, you can update it by{' '}
<SimpleInlineLinkText <SimpleInlineLinkText
label={_(msg`Click here to update your birthday`)} label={_(msg`Click here to update your birthdate`)}
style={[textStyles]} style={[textStyles]}
{...createStaticClick(() => { {...createStaticClick(() => {
birthdayControl.open() birthdateControl.open()
})}> })}>
clicking here clicking here
</SimpleInlineLinkText> </SimpleInlineLinkText>
@@ -132,7 +132,7 @@ export function NoAccessScreen() {
</Text> </Text>
))} ))}
{birthdayUpdateText} {birthdateUpdateText}
</View> </View>
<AccessSection /> <AccessSection />
@@ -141,12 +141,12 @@ export function NoAccessScreen() {
<View style={[a.gap_lg]}> <View style={[a.gap_lg]}>
<Text style={[textStyles]}> <Text style={[textStyles]}>
<Trans> <Trans>
Unfortunately, the birth date you have saved to your Unfortunately, the birthdate you have saved to your
profile makes you too young to access Bluesky. profile makes you too young to access Bluesky.
</Trans> </Trans>
</Text> </Text>
{birthdayUpdateText} {birthdateUpdateText}
</View> </View>
)} )}
</> </>
@@ -154,17 +154,17 @@ export function NoAccessScreen() {
<View style={[a.gap_lg]}> <View style={[a.gap_lg]}>
<Text style={[textStyles]}> <Text style={[textStyles]}>
<Trans> <Trans>
Looks like you haven't added your birth date. You must provide Looks like you haven't added your birthdate. You must provide
an accurate date of birth to use Bluesky. an accurate date of birth to use Bluesky.
</Trans> </Trans>
</Text> </Text>
<Button <Button
color="primary" color="primary"
size="large" size="large"
label={_(msg`Click here to update your birthday`)} label={_(msg`Click here to update your birthdate`)}
onPress={() => birthdayControl.open()}> onPress={() => birthdateControl.open()}>
<ButtonText> <ButtonText>
<Trans>Add your birth date</Trans> <Trans>Add your birthdate</Trans>
</ButtonText> </ButtonText>
</Button> </Button>
</View> </View>
@@ -187,7 +187,7 @@ export function NoAccessScreen() {
</View> </View>
</ScrollView> </ScrollView>
<BirthDateSettingsDialog control={birthdayControl} /> <BirthDateSettingsDialog control={birthdateControl} />
<AgeAssuranceRedirectDialog /> <AgeAssuranceRedirectDialog />
{/* {/*
+2 -2
View File
@@ -15,7 +15,7 @@ import debounce from 'lodash.debounce'
import {networkRetry} from '#/lib/async/retry' import {networkRetry} from '#/lib/async/retry'
import {PUBLIC_BSKY_SERVICE} from '#/lib/constants' import {PUBLIC_BSKY_SERVICE} from '#/lib/constants'
import {getAge} from '#/lib/strings/time' import {getAge} from '#/lib/strings/time'
import {snoozeBirthDateUpdateAllowedForDid} from '#/state/birthDate' import {snoozeBirthdateUpdateAllowedForDid} from '#/state/birthdate'
import {useAgent, useSession} from '#/state/session' import {useAgent, useSession} from '#/state/session'
import * as debug from '#/ageAssurance/debug' import * as debug from '#/ageAssurance/debug'
import {logger} from '#/ageAssurance/logger' import {logger} from '#/ageAssurance/logger'
@@ -337,7 +337,7 @@ export async function getOtherRequiredData({
isUserUnderMinimumAge(data.birthdate) && isUserUnderMinimumAge(data.birthdate) &&
!isLegacyBirthdateBug(data.birthdate) !isLegacyBirthdateBug(data.birthdate)
) { ) {
snoozeBirthDateUpdateAllowedForDid(did!) snoozeBirthdateUpdateAllowedForDid(did!)
} }
return data return data
+5 -5
View File
@@ -8,9 +8,9 @@ import {getAge, getDateAgo} from '#/lib/strings/time'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isIOS, isWeb} from '#/platform/detection' import {isIOS, isWeb} from '#/platform/detection'
import { import {
useBirthDateMutation, useBirthdateMutation,
useIsBirthDateUpdateAllowed, useIsBirthdateUpdateAllowed,
} from '#/state/birthDate' } from '#/state/birthdate'
import { import {
usePreferencesQuery, usePreferencesQuery,
type UsePreferencesQueryResponse, type UsePreferencesQueryResponse,
@@ -33,7 +33,7 @@ export function BirthDateSettingsDialog({
const t = useTheme() const t = useTheme()
const {_} = useLingui() const {_} = useLingui()
const {isLoading, error, data: preferences} = usePreferencesQuery() const {isLoading, error, data: preferences} = usePreferencesQuery()
const isBirthdateUpdateAllowed = useIsBirthDateUpdateAllowed() const isBirthdateUpdateAllowed = useIsBirthdateUpdateAllowed()
return ( return (
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}> <Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
@@ -112,7 +112,7 @@ function BirthdayInner({
isError, isError,
error, error,
mutateAsync: setBirthDate, mutateAsync: setBirthDate,
} = useBirthDateMutation() } = useBirthdateMutation()
const hasChanged = date !== preferences.birthDate const hasChanged = date !== preferences.birthDate
const age = getAge(new Date(date)) const age = getAge(new Date(date))
@@ -16,21 +16,21 @@ const BIRTHDATE_DELAY_HOURS = IS_DEV ? 0.001 : 48
* *
* Use {@link useIsBirthDateUpdateAllowed} to check if an update is allowed. * Use {@link useIsBirthDateUpdateAllowed} to check if an update is allowed.
*/ */
export function snoozeBirthDateUpdateAllowedForDid(did: string) { export function snoozeBirthdateUpdateAllowedForDid(did: string) {
account.set([did, 'birthDateLastUpdatedAt'], new Date().toISOString()) account.set([did, 'birthdateLastUpdatedAt'], new Date().toISOString())
} }
/** /**
* Returns whether a birthdate update is currently allowed, based on the * Returns whether a birthdate update is currently allowed, based on the
* last update timestamp stored locally. * last update timestamp stored locally.
*/ */
export function useIsBirthDateUpdateAllowed() { export function useIsBirthdateUpdateAllowed() {
const {currentAccount} = useSession() const {currentAccount} = useSession()
return useMemo(() => { return useMemo(() => {
if (!currentAccount) return false if (!currentAccount) return false
const lastUpdated = account.get([ const lastUpdated = account.get([
currentAccount.did, currentAccount.did,
'birthDateLastUpdatedAt', 'birthdateLastUpdatedAt',
]) ])
if (!lastUpdated) return true if (!lastUpdated) return true
const lastUpdatedDate = new Date(lastUpdated) const lastUpdatedDate = new Date(lastUpdated)
@@ -40,7 +40,7 @@ export function useIsBirthDateUpdateAllowed() {
}, [currentAccount]) }, [currentAccount])
} }
export function useBirthDateMutation() { export function useBirthdateMutation() {
const queryClient = useQueryClient() const queryClient = useQueryClient()
const agent = useAgent() const agent = useAgent()
const patchOtherRequiredData = usePatchAgeAssuranceOtherRequiredData() const patchOtherRequiredData = usePatchAgeAssuranceOtherRequiredData()
@@ -58,7 +58,7 @@ export function useBirthDateMutation() {
* birthdate, which may change the user's age assurance access level. * birthdate, which may change the user's age assurance access level.
*/ */
patchOtherRequiredData({birthdate: bday}) patchOtherRequiredData({birthdate: bday})
snoozeBirthDateUpdateAllowedForDid(agent.sessionManager.did!) snoozeBirthdateUpdateAllowedForDid(agent.sessionManager.did!)
}, },
}) })
} }
+2 -2
View File
@@ -25,7 +25,7 @@ import {
import {tryFetchGates} from '#/lib/statsig/statsig' import {tryFetchGates} from '#/lib/statsig/statsig'
import {getAge} from '#/lib/strings/time' import {getAge} from '#/lib/strings/time'
import {logger} from '#/logger' import {logger} from '#/logger'
import {snoozeBirthDateUpdateAllowedForDid} from '#/state/birthDate' import {snoozeBirthdateUpdateAllowedForDid} from '#/state/birthdate'
import {snoozeEmailConfirmationPrompt} from '#/state/shell/reminders' import {snoozeEmailConfirmationPrompt} from '#/state/shell/reminders'
import { import {
prefetchAgeAssuranceData, prefetchAgeAssuranceData,
@@ -185,7 +185,7 @@ export async function createAgentAndCreateAccount(
*/ */
setCreatedAtForDid({did: account.did, createdAt}) setCreatedAtForDid({did: account.did, createdAt})
setBirthdateForDid({did: account.did, birthdate}) setBirthdateForDid({did: account.did, birthdate})
snoozeBirthDateUpdateAllowedForDid(account.did) snoozeBirthdateUpdateAllowedForDid(account.did)
// do this last // do this last
const aa = prefetchAgeAssuranceData({agent}) const aa = prefetchAgeAssuranceData({agent})
+3 -2
View File
@@ -60,7 +60,8 @@ export type Account = {
searchAccountHistory?: string[] searchAccountHistory?: string[]
/** /**
* The ISO string of the user's birthday as last set locally. * The ISO date string of when this account's birthdate was last updated on
* this device.
*/ */
birthDateLastUpdatedAt?: string birthdateLastUpdatedAt?: string
} }