Settings: Set recovery email text (#5582)
This commit is contained in:
parent
3491a3b63b
commit
3405d62523
@ -6,7 +6,7 @@ import { withGlobal } from '../../../../global';
|
|||||||
|
|
||||||
import type { ApiSticker } from '../../../../api/types';
|
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 { IS_TOUCH_ENV } from '../../../../util/windowEnvironment';
|
||||||
|
|
||||||
import useAppLayout from '../../../../hooks/useAppLayout';
|
import useAppLayout from '../../../../hooks/useAppLayout';
|
||||||
@ -29,6 +29,7 @@ type OwnProps = {
|
|||||||
type StateProps = {
|
type StateProps = {
|
||||||
animatedEmoji: ApiSticker;
|
animatedEmoji: ApiSticker;
|
||||||
codeLength: number;
|
codeLength: number;
|
||||||
|
recoveryEmail: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ICON_SIZE = 160;
|
const ICON_SIZE = 160;
|
||||||
@ -42,6 +43,7 @@ const SettingsTwoFaEmailCode: FC<OwnProps & StateProps> = ({
|
|||||||
onSubmit,
|
onSubmit,
|
||||||
isActive,
|
isActive,
|
||||||
onReset,
|
onReset,
|
||||||
|
recoveryEmail,
|
||||||
}) => {
|
}) => {
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
@ -84,6 +86,9 @@ const SettingsTwoFaEmailCode: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="settings-content two-fa custom-scroll">
|
<div className="settings-content two-fa custom-scroll">
|
||||||
<div className="settings-content-header no-border">
|
<div className="settings-content-header no-border">
|
||||||
<AnimatedIconFromSticker sticker={animatedEmoji} size={ICON_SIZE} className="settings-content-icon" />
|
<AnimatedIconFromSticker sticker={animatedEmoji} size={ICON_SIZE} className="settings-content-icon" />
|
||||||
|
<p className="settings-item-description mb-3" dir="auto">
|
||||||
|
{lang('TwoStepAuth.ConfirmEmailDescription', recoveryEmail)}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="settings-item pt-0">
|
<div className="settings-item pt-0">
|
||||||
@ -102,8 +107,12 @@ const SettingsTwoFaEmailCode: FC<OwnProps & StateProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default memo(withGlobal<OwnProps>((global) => {
|
export default memo(withGlobal<OwnProps>((global) => {
|
||||||
|
const tabState = selectTabState(global);
|
||||||
|
const recoveryEmail = tabState.recoveryEmail;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
animatedEmoji: selectAnimatedEmoji(global, '💌'),
|
animatedEmoji: selectAnimatedEmoji(global, '💌'),
|
||||||
codeLength: global.twoFaSettings.waitingEmailCodeLength,
|
codeLength: global.twoFaSettings.waitingEmailCodeLength,
|
||||||
|
recoveryEmail,
|
||||||
};
|
};
|
||||||
})(SettingsTwoFaEmailCode));
|
})(SettingsTwoFaEmailCode));
|
||||||
|
|||||||
@ -105,6 +105,9 @@ const SettingsTwoFaSkippableForm: FC<OwnProps & StateProps> = ({
|
|||||||
<div className="settings-content two-fa custom-scroll">
|
<div className="settings-content two-fa custom-scroll">
|
||||||
<div className="settings-content-header no-border">
|
<div className="settings-content-header no-border">
|
||||||
<AnimatedIconFromSticker sticker={animatedEmoji} size={ICON_SIZE} className="settings-content-icon" />
|
<AnimatedIconFromSticker sticker={animatedEmoji} size={ICON_SIZE} className="settings-content-icon" />
|
||||||
|
<p className="settings-item-description mb-3" dir="auto">
|
||||||
|
{lang('RecoveryEmailSubtitle')}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="settings-item pt-0">
|
<div className="settings-item pt-0">
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
import type { ActionReturnType } from '../../types';
|
import type { ActionReturnType } from '../../types';
|
||||||
|
|
||||||
|
import { getCurrentTabId } from '../../../util/establishMultitabRole';
|
||||||
import { callApi } from '../../../api/gramjs';
|
import { callApi } from '../../../api/gramjs';
|
||||||
import { addActionHandler, getGlobal, setGlobal } from '../../index';
|
import { addActionHandler, getGlobal, setGlobal } from '../../index';
|
||||||
import { replaceSettings, updateTwoFaSettings } from '../../reducers';
|
import { replaceSettings, updateTwoFaSettings } from '../../reducers';
|
||||||
|
import { updateTabState } from '../../reducers/tabs';
|
||||||
|
|
||||||
addActionHandler('loadPasswordInfo', async (global): Promise<void> => {
|
addActionHandler('loadPasswordInfo', async (global): Promise<void> => {
|
||||||
const result = await callApi('getPasswordInfo');
|
const result = await callApi('getPasswordInfo');
|
||||||
@ -72,15 +74,22 @@ addActionHandler('updatePassword', async (global, actions, payload): Promise<voi
|
|||||||
addActionHandler('updateRecoveryEmail', async (global, actions, payload): Promise<void> => {
|
addActionHandler('updateRecoveryEmail', async (global, actions, payload): Promise<void> => {
|
||||||
const {
|
const {
|
||||||
currentPassword, email, onSuccess,
|
currentPassword, email, onSuccess,
|
||||||
|
tabId = getCurrentTabId(),
|
||||||
} = payload;
|
} = payload;
|
||||||
|
|
||||||
global = updateTwoFaSettings(global, { isLoading: true, errorKey: undefined });
|
global = updateTwoFaSettings(global, { isLoading: true, errorKey: undefined });
|
||||||
|
global = updateTabState(global, {
|
||||||
|
recoveryEmail: email,
|
||||||
|
}, tabId);
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|
||||||
const isSuccess = await callApi('updateRecoveryEmail', currentPassword, email);
|
const isSuccess = await callApi('updateRecoveryEmail', currentPassword, email);
|
||||||
|
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
global = updateTwoFaSettings(global, { isLoading: false, waitingEmailCodeLength: undefined });
|
global = updateTwoFaSettings(global, { isLoading: false, waitingEmailCodeLength: undefined });
|
||||||
|
global = updateTabState(global, {
|
||||||
|
recoveryEmail: undefined,
|
||||||
|
}, tabId);
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
|||||||
@ -190,7 +190,7 @@ export interface ActionPayloads {
|
|||||||
currentPassword: string;
|
currentPassword: string;
|
||||||
email: string;
|
email: string;
|
||||||
onSuccess: VoidFunction;
|
onSuccess: VoidFunction;
|
||||||
};
|
} & WithTabId;
|
||||||
clearPassword: {
|
clearPassword: {
|
||||||
currentPassword: string;
|
currentPassword: string;
|
||||||
onSuccess: VoidFunction;
|
onSuccess: VoidFunction;
|
||||||
|
|||||||
@ -199,6 +199,8 @@ export type TabState = {
|
|||||||
|
|
||||||
shouldPlayEffectInComposer?: true;
|
shouldPlayEffectInComposer?: true;
|
||||||
|
|
||||||
|
recoveryEmail?: string;
|
||||||
|
|
||||||
inlineBots: {
|
inlineBots: {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
byUsername: Record<string, false | InlineBotSettings>;
|
byUsername: Record<string, false | InlineBotSettings>;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user