Prevent double sending of requests.

This commit is contained in:
Paul 2021-09-19 13:47:25 +01:00
parent 3b9916c072
commit ce0749d9e8
2 changed files with 6 additions and 1 deletions

View file

@ -28,6 +28,7 @@ interface FormInputs {
export function ModifyAccountModal({ onClose, field }: Props) {
const client = useContext(AppContext);
const [processing, setProcessing] = useState(false);
const { handleSubmit, register, errors } = useForm<FormInputs>();
const [error, setError] = useState<string | undefined>(undefined);
@ -37,6 +38,8 @@ export function ModifyAccountModal({ onClose, field }: Props) {
new_email,
new_password,
}) => {
setProcessing(true);
try {
if (field === "email") {
await client.req("PATCH", "/auth/account/change/email", {
@ -59,6 +62,7 @@ export function ModifyAccountModal({ onClose, field }: Props) {
}
} catch (err) {
setError(takeError(err));
setProcessing(false);
}
};
@ -67,6 +71,7 @@ export function ModifyAccountModal({ onClose, field }: Props) {
visible={true}
onClose={onClose}
title={<Text id={`app.special.modals.account.change.${field}`} />}
disabled={processing}
actions={[
{
confirmation: true,

View file

@ -193,7 +193,7 @@ export const Account = observer(() => {
<CategoryButton
icon={<Trash size={24} color="var(--error)" />}
description={
"Delete your account, including all of your data."
"Delete your account, including all of your data. (sends an email to contact@revolt.chat)"
}
hover
action="external">