mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-25 16:40:58 -05:00
Prevent double sending of requests.
This commit is contained in:
parent
3b9916c072
commit
ce0749d9e8
2 changed files with 6 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue