Files
discord-decomp/modules/verification/native/ChangeEmailUtils.tsx
T
2026-11-01 12:12:55 +02:00

70 lines
2.4 KiB
TypeScript

// Metro module 9225 (f9226).
import { ChangeEmailFields, setChangeEmailError } from "../ChangeEmailStore";
import { saveAccountChanges } from "../../../actions/UserSettingsAccountActionCreators";
import { showInvalidUsernameToast } from "../../user_settings/account/native/showInvalidUsernameToastNative";
import { VerificationModalScenes } from "../../../ConstantsIOS";
export async function saveEmail(c26396_0, c26396_1, c26396_2) {
let r52;
let c26396_4;
let c30064_0, c30064_1, c30064_2, c30064_3, c30064_4, c30064_5, c30064_6;
L28: {
L27: {
c26396_4 = void 0;
c30064_0 = c26396_1;
c30064_1 = c26396_2;
c30064_2 = void 0;
c30064_3 = void 0;
c30064_4 = void 0;
c30064_5 = void 0;
c30064_6 = void 0;
c30064_2 = await saveAccountChanges(c26396_0, {
close: false
});
if (!c30064_2.ok) {
if (c30064_2.body?.username != null) {
showInvalidUsernameToast();
}
if (c30064_2.body?.email != null) {
(0, setChangeEmailError)(ChangeEmailFields.EMAIL, c30064_2.body.email[0]);
c30064_3 = c30064_0.getState().routes.length;
c30064_4 = (0, c30064_1)(VerificationModalScenes.ENTER_EMAIL);
if (c30064_4 !== -1) {
c30064_0.pop(c30064_3 - c30064_4 - 1);
break L27;
}
c30064_0.replace(VerificationModalScenes.ENTER_EMAIL);
break L27;
}
if (c30064_2.body?.email_token != null) {
(0, setChangeEmailError)(ChangeEmailFields.EMAIL_TOKEN, c30064_2.body.email_token[0]);
c30064_5 = c30064_0.getState().routes.length;
c30064_6 = (0, c30064_1)(VerificationModalScenes.CONFIRM_EMAIL_CHANGE_CODE);
if (c30064_6 !== -1) {
c30064_0.pop(c30064_5 - c30064_6 - 1);
} else {
c30064_0.replace(VerificationModalScenes.CONFIRM_EMAIL_CHANGE_CODE);
}
}
}
r52 = c30064_2;
break L28;
}
return null;
}
return r52;
}
export function finishChangeEmailFlow(a0, a1) {
a0.replace(VerificationModalScenes.CHANGE_EMAIL_COMPLETE, {
email: a1
});
}
export function finishVerifyEmailFlow(a0, a1) {
const length = a0.getState().routes.length;
const r15 = a1(VerificationModalScenes.RESEND_EMAIL);
if (r15 !== -1) {
a0.pop(length - r15);
} else {
a0.replace(VerificationModalScenes.RESEND_EMAIL);
}
}