diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 1fd8dc439e..c983593877 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -105,7 +105,6 @@ import TopicScreen from '#/screens/Topic' import {VideoFeed} from '#/screens/VideoFeed' import {useTheme} from '#/alf' import { - EmailDialog, EmailDialogScreenID, useEmailDialogControl, } from '#/components/dialogs/EmailDialog' @@ -773,7 +772,6 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) { }}> {children} - ) } diff --git a/src/components/dialogs/Context.tsx b/src/components/dialogs/Context.tsx index 6b8d688ed1..728044325b 100644 --- a/src/components/dialogs/Context.tsx +++ b/src/components/dialogs/Context.tsx @@ -1,6 +1,7 @@ import {createContext, useContext, useMemo, useState} from 'react' import * as Dialog from '#/components/Dialog' +import {type Screen} from '#/components/dialogs/EmailDialog/types' type Control = Dialog.DialogControlProps @@ -15,6 +16,7 @@ type ControlsContext = { mutedWordsDialogControl: Control signinDialogControl: Control inAppBrowserConsentControl: StatefulControl + emailDialogControl: StatefulControl } const ControlsContext = createContext(null) @@ -33,14 +35,21 @@ export function Provider({children}: React.PropsWithChildren<{}>) { const mutedWordsDialogControl = Dialog.useDialogControl() const signinDialogControl = Dialog.useDialogControl() const inAppBrowserConsentControl = useStatefulDialogControl() + const emailDialogControl = useStatefulDialogControl() const ctx = useMemo( () => ({ mutedWordsDialogControl, signinDialogControl, inAppBrowserConsentControl, + emailDialogControl, }), - [mutedWordsDialogControl, signinDialogControl, inAppBrowserConsentControl], + [ + mutedWordsDialogControl, + signinDialogControl, + inAppBrowserConsentControl, + emailDialogControl, + ], ) return ( diff --git a/src/components/dialogs/EmailDialog/index.tsx b/src/components/dialogs/EmailDialog/index.tsx index 9ccec5ffee..1f890e26ec 100644 --- a/src/components/dialogs/EmailDialog/index.tsx +++ b/src/components/dialogs/EmailDialog/index.tsx @@ -3,10 +3,8 @@ import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import * as Dialog from '#/components/Dialog' -import { - type StatefulControl, - useStatefulDialogControl, -} from '#/components/dialogs/Context' +import {type StatefulControl} from '#/components/dialogs/Context' +import {useGlobalDialogsControlContext} from '#/components/dialogs/Context' import {useAccountEmailState} from '#/components/dialogs/EmailDialog/data/useAccountEmailState' import {Manage2FA} from '#/components/dialogs/EmailDialog/screens/Manage2FA' import {Update} from '#/components/dialogs/EmailDialog/screens/Update' @@ -14,33 +12,33 @@ import {VerificationReminder} from '#/components/dialogs/EmailDialog/screens/Ver import {Verify} from '#/components/dialogs/EmailDialog/screens/Verify' import {type Screen, ScreenID} from '#/components/dialogs/EmailDialog/types' -export {useDialogControl} from '#/components/Dialog' export type {Screen} from '#/components/dialogs/EmailDialog/types' export {ScreenID as EmailDialogScreenID} from '#/components/dialogs/EmailDialog/types' export function useEmailDialogControl() { - return useStatefulDialogControl() + return useGlobalDialogsControlContext().emailDialogControl } -export function EmailDialog({control}: {control: StatefulControl}) { +export function EmailDialog() { const {_} = useLingui() + const emailDialogControl = useEmailDialogControl() const {isEmailVerified} = useAccountEmailState() const onClose = useCallback(() => { if (!isEmailVerified) { - if (control.value?.id === ScreenID.Verify) { - control.value.onCloseWithoutVerifying?.() + if (emailDialogControl.value?.id === ScreenID.Verify) { + emailDialogControl.value.onCloseWithoutVerifying?.() } } - }, [isEmailVerified, control]) + }, [isEmailVerified, emailDialogControl]) return ( - + - + diff --git a/src/screens/Messages/Conversation.tsx b/src/screens/Messages/Conversation.tsx index 6c78cd5217..e02a6c86d8 100644 --- a/src/screens/Messages/Conversation.tsx +++ b/src/screens/Messages/Conversation.tsx @@ -32,7 +32,6 @@ import {useSetMinimalShellMode} from '#/state/shell' import {MessagesList} from '#/screens/Messages/components/MessagesList' import {atoms as a, useBreakpoints, useTheme, web} from '#/alf' import { - EmailDialog, EmailDialogScreenID, useEmailDialogControl, } from '#/components/dialogs/EmailDialog' @@ -229,7 +228,6 @@ function InnerReady({ } /> )} - ) } diff --git a/src/screens/Settings/AccountSettings.tsx b/src/screens/Settings/AccountSettings.tsx index 1cf214f248..52bd8edd7b 100644 --- a/src/screens/Settings/AccountSettings.tsx +++ b/src/screens/Settings/AccountSettings.tsx @@ -10,7 +10,6 @@ import {atoms as a, useTheme} from '#/alf' import {useDialogControl} from '#/components/Dialog' import {BirthDateSettingsDialog} from '#/components/dialogs/BirthDateSettings' import { - EmailDialog, EmailDialogScreenID, useEmailDialogControl, } from '#/components/dialogs/EmailDialog' @@ -177,7 +176,6 @@ export function AccountSettingsScreen({}: Props) { - diff --git a/src/screens/Settings/components/Email2FAToggle.tsx b/src/screens/Settings/components/Email2FAToggle.tsx index c8f2577d0e..584026298c 100644 --- a/src/screens/Settings/components/Email2FAToggle.tsx +++ b/src/screens/Settings/components/Email2FAToggle.tsx @@ -5,7 +5,6 @@ import {useLingui} from '@lingui/react' import {useSession} from '#/state/session' import {useDialogControl} from '#/components/Dialog' import { - EmailDialog, EmailDialogScreenID, useEmailDialogControl, } from '#/components/dialogs/EmailDialog' @@ -27,7 +26,6 @@ export function Email2FAToggle() { return ( <> - 1 return ( - + diff --git a/src/view/shell/index.web.tsx b/src/view/shell/index.web.tsx index e194a49de8..ce98044c7e 100644 --- a/src/view/shell/index.web.tsx +++ b/src/view/shell/index.web.tsx @@ -8,7 +8,7 @@ import {RemoveScrollBar} from 'react-remove-scroll-bar' import {useColorSchemeStyle} from '#/lib/hooks/useColorSchemeStyle' import {useIntentHandler} from '#/lib/hooks/useIntentHandler' import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' -import {NavigationProp} from '#/lib/routes/types' +import {type NavigationProp} from '#/lib/routes/types' import {colors} from '#/lib/styles' import {useIsDrawerOpen, useSetDrawerOpen} from '#/state/shell' import {useComposerKeyboardShortcut} from '#/state/shell/composer/useComposerKeyboardShortcut' @@ -17,6 +17,7 @@ import {Lightbox} from '#/view/com/lightbox/Lightbox' import {ModalsContainer} from '#/view/com/modals/Modal' import {ErrorBoundary} from '#/view/com/util/ErrorBoundary' import {atoms as a, select, useTheme} from '#/alf' +import {EmailDialog} from '#/components/dialogs/EmailDialog' import {MutedWordsDialog} from '#/components/dialogs/MutedWords' import {SigninDialog} from '#/components/dialogs/Signin' import {Outlet as PortalOutlet} from '#/components/Portal' @@ -67,6 +68,7 @@ function ShellInner() { +