diff --git a/src/components/left/settings/twoFa/SettingsTwoFaEmailCode.tsx b/src/components/left/settings/twoFa/SettingsTwoFaEmailCode.tsx index 8acebc9a5..594c8cedd 100644 --- a/src/components/left/settings/twoFa/SettingsTwoFaEmailCode.tsx +++ b/src/components/left/settings/twoFa/SettingsTwoFaEmailCode.tsx @@ -6,7 +6,7 @@ import { withGlobal } from '../../../../global'; import type { ApiSticker } from '../../../../api/types'; -import { selectAnimatedEmoji } from '../../../../global/selectors'; +import { selectAnimatedEmoji, selectTabState } from '../../../../global/selectors'; import { IS_TOUCH_ENV } from '../../../../util/windowEnvironment'; import useAppLayout from '../../../../hooks/useAppLayout'; @@ -29,6 +29,7 @@ type OwnProps = { type StateProps = { animatedEmoji: ApiSticker; codeLength: number; + recoveryEmail: string; }; const ICON_SIZE = 160; @@ -42,6 +43,7 @@ const SettingsTwoFaEmailCode: FC = ({ onSubmit, isActive, onReset, + recoveryEmail, }) => { // eslint-disable-next-line no-null/no-null const inputRef = useRef(null); @@ -84,6 +86,9 @@ const SettingsTwoFaEmailCode: FC = ({
+

+ {lang('TwoStepAuth.ConfirmEmailDescription', recoveryEmail)} +

@@ -102,8 +107,12 @@ const SettingsTwoFaEmailCode: FC = ({ }; export default memo(withGlobal((global) => { + const tabState = selectTabState(global); + const recoveryEmail = tabState.recoveryEmail; + return { animatedEmoji: selectAnimatedEmoji(global, '💌'), codeLength: global.twoFaSettings.waitingEmailCodeLength, + recoveryEmail, }; })(SettingsTwoFaEmailCode)); diff --git a/src/components/left/settings/twoFa/SettingsTwoFaSkippableForm.tsx b/src/components/left/settings/twoFa/SettingsTwoFaSkippableForm.tsx index d7b0c6da3..27c276a07 100644 --- a/src/components/left/settings/twoFa/SettingsTwoFaSkippableForm.tsx +++ b/src/components/left/settings/twoFa/SettingsTwoFaSkippableForm.tsx @@ -105,6 +105,9 @@ const SettingsTwoFaSkippableForm: FC = ({
+

+ {lang('RecoveryEmailSubtitle')} +

diff --git a/src/global/actions/api/twoFaSettings.ts b/src/global/actions/api/twoFaSettings.ts index a2ea5dd4f..da2f240ce 100644 --- a/src/global/actions/api/twoFaSettings.ts +++ b/src/global/actions/api/twoFaSettings.ts @@ -1,8 +1,10 @@ import type { ActionReturnType } from '../../types'; +import { getCurrentTabId } from '../../../util/establishMultitabRole'; import { callApi } from '../../../api/gramjs'; import { addActionHandler, getGlobal, setGlobal } from '../../index'; import { replaceSettings, updateTwoFaSettings } from '../../reducers'; +import { updateTabState } from '../../reducers/tabs'; addActionHandler('loadPasswordInfo', async (global): Promise => { const result = await callApi('getPasswordInfo'); @@ -72,15 +74,22 @@ addActionHandler('updatePassword', async (global, actions, payload): Promise => { const { currentPassword, email, onSuccess, + tabId = getCurrentTabId(), } = payload; global = updateTwoFaSettings(global, { isLoading: true, errorKey: undefined }); + global = updateTabState(global, { + recoveryEmail: email, + }, tabId); setGlobal(global); const isSuccess = await callApi('updateRecoveryEmail', currentPassword, email); global = getGlobal(); global = updateTwoFaSettings(global, { isLoading: false, waitingEmailCodeLength: undefined }); + global = updateTabState(global, { + recoveryEmail: undefined, + }, tabId); setGlobal(global); if (isSuccess) { diff --git a/src/global/types/actions.ts b/src/global/types/actions.ts index b152c08ae..cb23db0fe 100644 --- a/src/global/types/actions.ts +++ b/src/global/types/actions.ts @@ -190,7 +190,7 @@ export interface ActionPayloads { currentPassword: string; email: string; onSuccess: VoidFunction; - }; + } & WithTabId; clearPassword: { currentPassword: string; onSuccess: VoidFunction; diff --git a/src/global/types/tabState.ts b/src/global/types/tabState.ts index 4dce93fd5..c13405947 100644 --- a/src/global/types/tabState.ts +++ b/src/global/types/tabState.ts @@ -199,6 +199,8 @@ export type TabState = { shouldPlayEffectInComposer?: true; + recoveryEmail?: string; + inlineBots: { isLoading: boolean; byUsername: Record;