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 {isWeb} from '#/platform/detection'
import {isNative} from '#/platform/detection'
import {useIsBirthDateUpdateAllowed} from '#/state/birthDate'
import {useIsBirthdateUpdateAllowed} from '#/state/birthdate'
import {useSessionApi} from '#/state/session'
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
import {Admonition} from '#/components/Admonition'
@@ -42,10 +42,10 @@ export function NoAccessScreen() {
const {_} = useLingui()
const {gtPhone} = useBreakpoints()
const insets = useSafeAreaInsets()
const birthdayControl = useDialogControl()
const birthdateControl = useDialogControl()
const {data} = useAgeAssuranceDataContext()
const region = useAgeAssuranceRegionConfig()
const isBirthdateUpdateAllowed = useIsBirthDateUpdateAllowed()
const isBirthdateUpdateAllowed = useIsBirthdateUpdateAllowed()
const {logoutCurrentAccount} = useSessionApi()
const isAARegion = !!region
@@ -78,15 +78,15 @@ export function NoAccessScreen() {
logoutCurrentAccount('AgeAssuranceNoAccessScreen')
}, [logoutCurrentAccount])
const birthdayUpdateText = canUpdateBirthday ? (
const birthdateUpdateText = canUpdateBirthday ? (
<Text style={[textStyles]}>
<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
label={_(msg`Click here to update your birthday`)}
label={_(msg`Click here to update your birthdate`)}
style={[textStyles]}
{...createStaticClick(() => {
birthdayControl.open()
birthdateControl.open()
})}>
clicking here
</SimpleInlineLinkText>
@@ -132,7 +132,7 @@ export function NoAccessScreen() {
</Text>
))}
{birthdayUpdateText}
{birthdateUpdateText}
</View>
<AccessSection />
@@ -141,12 +141,12 @@ export function NoAccessScreen() {
<View style={[a.gap_lg]}>
<Text style={[textStyles]}>
<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.
</Trans>
</Text>
{birthdayUpdateText}
{birthdateUpdateText}
</View>
)}
</>
@@ -154,17 +154,17 @@ export function NoAccessScreen() {
<View style={[a.gap_lg]}>
<Text style={[textStyles]}>
<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.
</Trans>
</Text>
<Button
color="primary"
size="large"
label={_(msg`Click here to update your birthday`)}
onPress={() => birthdayControl.open()}>
label={_(msg`Click here to update your birthdate`)}
onPress={() => birthdateControl.open()}>
<ButtonText>
<Trans>Add your birth date</Trans>
<Trans>Add your birthdate</Trans>
</ButtonText>
</Button>
</View>
@@ -187,7 +187,7 @@ export function NoAccessScreen() {
</View>
</ScrollView>
<BirthDateSettingsDialog control={birthdayControl} />
<BirthDateSettingsDialog control={birthdateControl} />
<AgeAssuranceRedirectDialog />
{/*
+2 -2
View File
@@ -15,7 +15,7 @@ import debounce from 'lodash.debounce'
import {networkRetry} from '#/lib/async/retry'
import {PUBLIC_BSKY_SERVICE} from '#/lib/constants'
import {getAge} from '#/lib/strings/time'
import {snoozeBirthDateUpdateAllowedForDid} from '#/state/birthDate'
import {snoozeBirthdateUpdateAllowedForDid} from '#/state/birthdate'
import {useAgent, useSession} from '#/state/session'
import * as debug from '#/ageAssurance/debug'
import {logger} from '#/ageAssurance/logger'
@@ -337,7 +337,7 @@ export async function getOtherRequiredData({
isUserUnderMinimumAge(data.birthdate) &&
!isLegacyBirthdateBug(data.birthdate)
) {
snoozeBirthDateUpdateAllowedForDid(did!)
snoozeBirthdateUpdateAllowedForDid(did!)
}
return data
+5 -5
View File
@@ -8,9 +8,9 @@ import {getAge, getDateAgo} from '#/lib/strings/time'
import {logger} from '#/logger'
import {isIOS, isWeb} from '#/platform/detection'
import {
useBirthDateMutation,
useIsBirthDateUpdateAllowed,
} from '#/state/birthDate'
useBirthdateMutation,
useIsBirthdateUpdateAllowed,
} from '#/state/birthdate'
import {
usePreferencesQuery,
type UsePreferencesQueryResponse,
@@ -33,7 +33,7 @@ export function BirthDateSettingsDialog({
const t = useTheme()
const {_} = useLingui()
const {isLoading, error, data: preferences} = usePreferencesQuery()
const isBirthdateUpdateAllowed = useIsBirthDateUpdateAllowed()
const isBirthdateUpdateAllowed = useIsBirthdateUpdateAllowed()
return (
<Dialog.Outer control={control} nativeOptions={{preventExpansion: true}}>
@@ -112,7 +112,7 @@ function BirthdayInner({
isError,
error,
mutateAsync: setBirthDate,
} = useBirthDateMutation()
} = useBirthdateMutation()
const hasChanged = date !== preferences.birthDate
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.
*/
export function snoozeBirthDateUpdateAllowedForDid(did: string) {
account.set([did, 'birthDateLastUpdatedAt'], new Date().toISOString())
export function snoozeBirthdateUpdateAllowedForDid(did: string) {
account.set([did, 'birthdateLastUpdatedAt'], new Date().toISOString())
}
/**
* Returns whether a birthdate update is currently allowed, based on the
* last update timestamp stored locally.
*/
export function useIsBirthDateUpdateAllowed() {
export function useIsBirthdateUpdateAllowed() {
const {currentAccount} = useSession()
return useMemo(() => {
if (!currentAccount) return false
const lastUpdated = account.get([
currentAccount.did,
'birthDateLastUpdatedAt',
'birthdateLastUpdatedAt',
])
if (!lastUpdated) return true
const lastUpdatedDate = new Date(lastUpdated)
@@ -40,7 +40,7 @@ export function useIsBirthDateUpdateAllowed() {
}, [currentAccount])
}
export function useBirthDateMutation() {
export function useBirthdateMutation() {
const queryClient = useQueryClient()
const agent = useAgent()
const patchOtherRequiredData = usePatchAgeAssuranceOtherRequiredData()
@@ -58,7 +58,7 @@ export function useBirthDateMutation() {
* birthdate, which may change the user's age assurance access level.
*/
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 {getAge} from '#/lib/strings/time'
import {logger} from '#/logger'
import {snoozeBirthDateUpdateAllowedForDid} from '#/state/birthDate'
import {snoozeBirthdateUpdateAllowedForDid} from '#/state/birthdate'
import {snoozeEmailConfirmationPrompt} from '#/state/shell/reminders'
import {
prefetchAgeAssuranceData,
@@ -185,7 +185,7 @@ export async function createAgentAndCreateAccount(
*/
setCreatedAtForDid({did: account.did, createdAt})
setBirthdateForDid({did: account.did, birthdate})
snoozeBirthDateUpdateAllowedForDid(account.did)
snoozeBirthdateUpdateAllowedForDid(account.did)
// do this last
const aa = prefetchAgeAssuranceData({agent})
+3 -2
View File
@@ -60,7 +60,8 @@ export type Account = {
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
}