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
This commit is contained in:
@@ -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 (
|
|
||||||
<Dialog.Outer control={control} onClose={onClose}>
|
|
||||||
<Dialog.Handle />
|
|
||||||
<Dialog.ScrollableInner label={_(msg`Introducing new font settings`)}>
|
|
||||||
<View style={[a.gap_xl]}>
|
|
||||||
<View style={[a.gap_md]}>
|
|
||||||
<Text style={[a.text_3xl, a.font_heavy]}>
|
|
||||||
<Trans>New font settings ✨</Trans>
|
|
||||||
</Text>
|
|
||||||
<Text style={[a.text_lg, a.leading_snug, {maxWidth: 400}]}>
|
|
||||||
<Trans>
|
|
||||||
We're introducing a new theme font, along with adjustable font
|
|
||||||
sizing.
|
|
||||||
</Trans>
|
|
||||||
</Text>
|
|
||||||
<Text
|
|
||||||
style={[a.text_sm, a.leading_snug, t.atoms.text_contrast_medium]}>
|
|
||||||
<Trans>
|
|
||||||
You can adjust these in your Appearance Settings later.
|
|
||||||
</Trans>
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<Divider />
|
|
||||||
|
|
||||||
<View style={[a.gap_lg]}>
|
|
||||||
<AppearanceToggleButtonGroup
|
|
||||||
title={_(msg`Font`)}
|
|
||||||
description={_(
|
|
||||||
msg`For the best experience, we recommend using the theme font.`,
|
|
||||||
)}
|
|
||||||
icon={Aa}
|
|
||||||
items={[
|
|
||||||
{
|
|
||||||
label: _(msg`System`),
|
|
||||||
name: 'system',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: _(msg`Theme`),
|
|
||||||
name: 'theme',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
values={[fonts.family]}
|
|
||||||
onChange={onChangeFontFamily}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<AppearanceToggleButtonGroup
|
|
||||||
title={_(msg`Font size`)}
|
|
||||||
icon={TextSize}
|
|
||||||
items={[
|
|
||||||
{
|
|
||||||
label: _(msg`Smaller`),
|
|
||||||
name: '-1',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: _(msg`Default`),
|
|
||||||
name: '0',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: _(msg`Larger`),
|
|
||||||
name: '1',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
values={[fonts.scale]}
|
|
||||||
onChange={onChangeFontScale}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<Dialog.Close />
|
|
||||||
</Dialog.ScrollableInner>
|
|
||||||
</Dialog.Outer>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,6 @@ import {useOnboardingState} from '#/state/shell'
|
|||||||
/*
|
/*
|
||||||
* NUXs
|
* NUXs
|
||||||
*/
|
*/
|
||||||
import {NeueTypography} from '#/components/dialogs/nuxs/NeueTypography'
|
|
||||||
import {isSnoozed, snooze, unsnooze} from '#/components/dialogs/nuxs/snoozing'
|
import {isSnoozed, snooze, unsnooze} from '#/components/dialogs/nuxs/snoozing'
|
||||||
import {IS_DEV} from '#/env'
|
import {IS_DEV} from '#/env'
|
||||||
|
|
||||||
@@ -36,19 +35,7 @@ const queuedNuxs: {
|
|||||||
currentProfile: AppBskyActorDefs.ProfileViewDetailed
|
currentProfile: AppBskyActorDefs.ProfileViewDetailed
|
||||||
preferences: UsePreferencesQueryResponse
|
preferences: UsePreferencesQueryResponse
|
||||||
}) => boolean
|
}) => 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<Context>({
|
const Context = React.createContext<Context>({
|
||||||
activeNux: undefined,
|
activeNux: undefined,
|
||||||
@@ -66,7 +53,14 @@ export function NuxDialogs() {
|
|||||||
const onboardingActive = useOnboardingState().isActive
|
const onboardingActive = useOnboardingState().isActive
|
||||||
|
|
||||||
const isLoading =
|
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 ? (
|
return !isLoading ? (
|
||||||
<Inner
|
<Inner
|
||||||
currentAccount={currentAccount}
|
currentAccount={currentAccount}
|
||||||
@@ -174,7 +168,7 @@ function Inner({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Context.Provider value={ctx}>
|
<Context.Provider value={ctx}>
|
||||||
{activeNux === Nux.NeueTypography && <NeueTypography />}
|
{/*For example, activeNux === Nux.NeueTypography && <NeueTypography />*/}
|
||||||
</Context.Provider>
|
</Context.Provider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,14 +127,20 @@ export function StepFinished() {
|
|||||||
})(),
|
})(),
|
||||||
(async () => {
|
(async () => {
|
||||||
const {imageUri, imageMime} = profileStepResults
|
const {imageUri, imageMime} = profileStepResults
|
||||||
if (imageUri && imageMime) {
|
const blobPromise =
|
||||||
const blobPromise = uploadBlob(agent, imageUri, imageMime)
|
imageUri && imageMime
|
||||||
|
? uploadBlob(agent, imageUri, imageMime)
|
||||||
|
: undefined
|
||||||
|
|
||||||
await agent.upsertProfile(async existing => {
|
await agent.upsertProfile(async existing => {
|
||||||
existing = existing ?? {}
|
existing = existing ?? {}
|
||||||
|
|
||||||
|
if (blobPromise) {
|
||||||
const res = await blobPromise
|
const res = await blobPromise
|
||||||
if (res.data.blob) {
|
if (res.data.blob) {
|
||||||
existing.avatar = res.data.blob
|
existing.avatar = res.data.blob
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (starterPack) {
|
if (starterPack) {
|
||||||
existing.joinedViaStarterPack = {
|
existing.joinedViaStarterPack = {
|
||||||
@@ -151,7 +157,6 @@ export function StepFinished() {
|
|||||||
existing.createdAt = new Date().toISOString()
|
existing.createdAt = new Date().toISOString()
|
||||||
return existing
|
return existing
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
logEvent('onboarding:finished:avatarResult', {
|
logEvent('onboarding:finished:avatarResult', {
|
||||||
avatarResult: profileStepResults.isCreatedAvatar
|
avatarResult: profileStepResults.isCreatedAvatar
|
||||||
|
|||||||
Reference in New Issue
Block a user