From edaf230612f688512c71a66a99742e558620ebd3 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 16 Nov 2024 21:39:47 +0000 Subject: Remove typography NUX and consistently call upsertProfile (#6424) * Make profile upsert unconditional * Remove Typography NUX * Early exit NUXes on unknown creation date * Clarify via comment --- src/components/dialogs/nuxs/NeueTypography.tsx | 117 ------------------------- src/components/dialogs/nuxs/index.tsx | 26 +++--- src/screens/Onboarding/StepFinished.tsx | 41 +++++---- 3 files changed, 33 insertions(+), 151 deletions(-) delete mode 100644 src/components/dialogs/nuxs/NeueTypography.tsx (limited to 'src') diff --git a/src/components/dialogs/nuxs/NeueTypography.tsx b/src/components/dialogs/nuxs/NeueTypography.tsx deleted file mode 100644 index f29dc356d..000000000 --- a/src/components/dialogs/nuxs/NeueTypography.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import React from 'react' -import {View} from 'react-native' -import {msg, Trans} from '@lingui/macro' -import {useLingui} from '@lingui/react' - -import {AppearanceToggleButtonGroup} from '#/screens/Settings/AppearanceSettings' -import {atoms as a, useAlf, useTheme} from '#/alf' -import * as Dialog from '#/components/Dialog' -import {useNuxDialogContext} from '#/components/dialogs/nuxs' -import {Divider} from '#/components/Divider' -import {TextSize_Stroke2_Corner0_Rounded as TextSize} from '#/components/icons/TextSize' -import {TitleCase_Stroke2_Corner0_Rounded as Aa} from '#/components/icons/TitleCase' -import {Text} from '#/components/Typography' - -export function NeueTypography() { - const t = useTheme() - const {_} = useLingui() - const nuxDialogs = useNuxDialogContext() - const control = Dialog.useDialogControl() - const {fonts} = useAlf() - - Dialog.useAutoOpen(control, 3e3) - - const onClose = React.useCallback(() => { - nuxDialogs.dismissActiveNux() - }, [nuxDialogs]) - - const onChangeFontFamily = React.useCallback( - (values: string[]) => { - const next = values[0] === 'system' ? 'system' : 'theme' - fonts.setFontFamily(next) - }, - [fonts], - ) - - const onChangeFontScale = React.useCallback( - (values: string[]) => { - const next = values[0] || ('0' as any) - fonts.setFontScale(next) - }, - [fonts], - ) - - return ( - - - - - - - New font settings ✨ - - - - We're introducing a new theme font, along with adjustable font - sizing. - - - - - You can adjust these in your Appearance Settings later. - - - - - - - - - - - - - - - - - ) -} diff --git a/src/components/dialogs/nuxs/index.tsx b/src/components/dialogs/nuxs/index.tsx index d17615aeb..701ae84e6 100644 --- a/src/components/dialogs/nuxs/index.tsx +++ b/src/components/dialogs/nuxs/index.tsx @@ -19,7 +19,6 @@ import {useOnboardingState} from '#/state/shell' /* * NUXs */ -import {NeueTypography} from '#/components/dialogs/nuxs/NeueTypography' import {isSnoozed, snooze, unsnooze} from '#/components/dialogs/nuxs/snoozing' import {IS_DEV} from '#/env' @@ -36,19 +35,7 @@ const queuedNuxs: { currentProfile: AppBskyActorDefs.ProfileViewDetailed preferences: UsePreferencesQueryResponse }) => boolean -}[] = [ - { - id: Nux.NeueTypography, - enabled(props) { - if (props.currentProfile.createdAt) { - if (new Date(props.currentProfile.createdAt) < new Date('2024-10-09')) { - return true - } - } - return false - }, - }, -] +}[] = [] const Context = React.createContext({ activeNux: undefined, @@ -66,7 +53,14 @@ export function NuxDialogs() { const onboardingActive = useOnboardingState().isActive const isLoading = - !currentAccount || !preferences || !profile || onboardingActive + onboardingActive || + !currentAccount || + !preferences || + !profile || + // Profile isn't legit ready until createdAt is a real date. + !profile.createdAt || + profile.createdAt === '0001-01-01T00:00:00.000Z' // TODO: Fix this in AppView. + return !isLoading ? ( - {activeNux === Nux.NeueTypography && } + {/*For example, activeNux === Nux.NeueTypography && */} ) } diff --git a/src/screens/Onboarding/StepFinished.tsx b/src/screens/Onboarding/StepFinished.tsx index fdc0a3eb7..0d8971b6f 100644 --- a/src/screens/Onboarding/StepFinished.tsx +++ b/src/screens/Onboarding/StepFinished.tsx @@ -127,31 +127,36 @@ export function StepFinished() { })(), (async () => { const {imageUri, imageMime} = profileStepResults - if (imageUri && imageMime) { - const blobPromise = uploadBlob(agent, imageUri, imageMime) - await agent.upsertProfile(async existing => { - existing = existing ?? {} + const blobPromise = + imageUri && imageMime + ? uploadBlob(agent, imageUri, imageMime) + : undefined + + await agent.upsertProfile(async existing => { + existing = existing ?? {} + + if (blobPromise) { const res = await blobPromise if (res.data.blob) { existing.avatar = res.data.blob } + } - if (starterPack) { - existing.joinedViaStarterPack = { - uri: starterPack.uri, - cid: starterPack.cid, - } + if (starterPack) { + existing.joinedViaStarterPack = { + uri: starterPack.uri, + cid: starterPack.cid, } + } - existing.displayName = '' - // HACKFIX - // creating a bunch of identical profile objects is breaking the relay - // tossing this unspecced field onto it to reduce the size of the problem - // -prf - existing.createdAt = new Date().toISOString() - return existing - }) - } + existing.displayName = '' + // HACKFIX + // creating a bunch of identical profile objects is breaking the relay + // tossing this unspecced field onto it to reduce the size of the problem + // -prf + existing.createdAt = new Date().toISOString() + return existing + }) logEvent('onboarding:finished:avatarResult', { avatarResult: profileStepResults.isCreatedAvatar -- cgit 1.4.1