From 3b8c5e9699c07539cbd8973a257fb0574df47f3c Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 4 Dec 2025 10:12:08 -0600 Subject: [PATCH] Standarize on birthdate --- .../components/NoAccessScreen.tsx | 30 +++++++++---------- src/ageAssurance/data.tsx | 4 +-- src/components/dialogs/BirthDateSettings.tsx | 10 +++---- src/state/{birthDate.ts => birthdate.ts} | 12 ++++---- src/state/session/agent.ts | 4 +-- src/storage/schema.ts | 5 ++-- 6 files changed, 33 insertions(+), 32 deletions(-) rename src/state/{birthDate.ts => birthdate.ts} (85%) diff --git a/src/ageAssurance/components/NoAccessScreen.tsx b/src/ageAssurance/components/NoAccessScreen.tsx index d55fa5846f..70284dbc73 100644 --- a/src/ageAssurance/components/NoAccessScreen.tsx +++ b/src/ageAssurance/components/NoAccessScreen.tsx @@ -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 ? ( - If your birth date is not accurate, you can update it by{' '} + If your birthdate is not accurate, you can update it by{' '} { - birthdayControl.open() + birthdateControl.open() })}> clicking here @@ -132,7 +132,7 @@ export function NoAccessScreen() { ))} - {birthdayUpdateText} + {birthdateUpdateText} @@ -141,12 +141,12 @@ export function NoAccessScreen() { - 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. - {birthdayUpdateText} + {birthdateUpdateText} )} @@ -154,17 +154,17 @@ export function NoAccessScreen() { - 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. @@ -187,7 +187,7 @@ export function NoAccessScreen() { - + {/* diff --git a/src/ageAssurance/data.tsx b/src/ageAssurance/data.tsx index e3a7580a28..1e21669285 100644 --- a/src/ageAssurance/data.tsx +++ b/src/ageAssurance/data.tsx @@ -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 diff --git a/src/components/dialogs/BirthDateSettings.tsx b/src/components/dialogs/BirthDateSettings.tsx index 4d593b53de..bf4af528a3 100644 --- a/src/components/dialogs/BirthDateSettings.tsx +++ b/src/components/dialogs/BirthDateSettings.tsx @@ -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 ( @@ -112,7 +112,7 @@ function BirthdayInner({ isError, error, mutateAsync: setBirthDate, - } = useBirthDateMutation() + } = useBirthdateMutation() const hasChanged = date !== preferences.birthDate const age = getAge(new Date(date)) diff --git a/src/state/birthDate.ts b/src/state/birthdate.ts similarity index 85% rename from src/state/birthDate.ts rename to src/state/birthdate.ts index 2814a1be46..bfa3e9561f 100644 --- a/src/state/birthDate.ts +++ b/src/state/birthdate.ts @@ -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!) }, }) } diff --git a/src/state/session/agent.ts b/src/state/session/agent.ts index c391171542..5c8ce3b97f 100644 --- a/src/state/session/agent.ts +++ b/src/state/session/agent.ts @@ -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}) diff --git a/src/storage/schema.ts b/src/storage/schema.ts index ac3c1054d7..4cc9782262 100644 --- a/src/storage/schema.ts +++ b/src/storage/schema.ts @@ -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 }