From 2c9ce84df1350ffde1c40ffceb8378d7445a917a Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Mon, 16 Sep 2024 13:58:26 -0500 Subject: [PATCH] Add fallback --- src/components/Prompt.tsx | 4 +- .../dialogs/nuxs/TenMillion/Trigger.tsx | 72 ++++++++++++++++--- .../dialogs/nuxs/TenMillion/index.tsx | 5 ++ 3 files changed, 70 insertions(+), 11 deletions(-) diff --git a/src/components/Prompt.tsx b/src/components/Prompt.tsx index 86cb5c315a..7836bbef95 100644 --- a/src/components/Prompt.tsx +++ b/src/components/Prompt.tsx @@ -59,7 +59,9 @@ export function Outer({ export function TitleText({children}: React.PropsWithChildren<{}>) { const {titleId} = React.useContext(Context) return ( - + {children} ) diff --git a/src/components/dialogs/nuxs/TenMillion/Trigger.tsx b/src/components/dialogs/nuxs/TenMillion/Trigger.tsx index 7df8a1dccb..9616b3b1d3 100644 --- a/src/components/dialogs/nuxs/TenMillion/Trigger.tsx +++ b/src/components/dialogs/nuxs/TenMillion/Trigger.tsx @@ -1,34 +1,86 @@ import React from 'react' +import {View} from 'react-native' import Svg, {Circle, Path} from 'react-native-svg' -import {msg} from '@lingui/macro' +import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {Nux, useUpsertNuxMutation} from '#/state/queries/nuxs' -import {ViewStyleProp} from '#/alf' +import {atoms as a, ViewStyleProp} from '#/alf' import {Button, ButtonProps} from '#/components/Button' +import * as Dialog from '#/components/Dialog' +import {InlineLinkText} from '#/components/Link' +import * as Prompt from '#/components/Prompt' import {TenMillion} from './' export function Trigger({children}: {children: ButtonProps['children']}) { const {_} = useLingui() const {mutate: upsertNux} = useUpsertNuxMutation() const [show, setShow] = React.useState(false) + const [fallback, setFallback] = React.useState(false) + const control = Prompt.usePromptControl() const handleOnPress = () => { - setShow(true) - upsertNux({ - id: Nux.TenMillionDialog, - completed: true, - data: undefined, - }) + if (!fallback) { + setShow(true) + upsertNux({ + id: Nux.TenMillionDialog, + completed: true, + data: undefined, + }) + } else { + control.open() + } + } + + const onHandleFallback = () => { + setFallback(true) + control.open() } return ( <> - - {show && setShow(false)} />} + {show && !fallback && ( + setShow(false)} + onFallback={onHandleFallback} + /> + )} + + + + + Bluesky is celebrating 10 million users! + + + + + Together, we're rebuilding the social internet. We're glad you're + here. + + + + + To learn more,{' '} + { + control.close() + }} + style={[a.text_md, a.leading_snug]}> + check out our post. + + + + + ) } diff --git a/src/components/dialogs/nuxs/TenMillion/index.tsx b/src/components/dialogs/nuxs/TenMillion/index.tsx index f3a8abf462..edf6f940cb 100644 --- a/src/components/dialogs/nuxs/TenMillion/index.tsx +++ b/src/components/dialogs/nuxs/TenMillion/index.tsx @@ -90,9 +90,11 @@ function Frame({children}: {children: React.ReactNode}) { export function TenMillion({ showTimeout, onClose, + onFallback, }: { showTimeout?: number onClose?: () => void + onFallback?: () => void }) { const agent = useAgent() const nuxDialogs = useNuxDialogContext() @@ -126,6 +128,7 @@ export function TenMillion({ } else { // should be rare nuxDialogs.dismissActiveNux() + onFallback?.() } } } @@ -134,6 +137,7 @@ export function TenMillion({ fetching.current = true networkRetry(3, fetchUserNumber).catch(() => { nuxDialogs.dismissActiveNux() + onFallback?.() }) } }, [ @@ -142,6 +146,7 @@ export function TenMillion({ setUserNumber, nuxDialogs.dismissActiveNux, nuxDialogs, + onFallback, ]) return userNumber ? (