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) {
|
export function ModifyAccountModal({ onClose, field }: Props) {
|
||||||
const client = useContext(AppContext);
|
const client = useContext(AppContext);
|
||||||
|
const [processing, setProcessing] = useState(false);
|
||||||
const { handleSubmit, register, errors } = useForm<FormInputs>();
|
const { handleSubmit, register, errors } = useForm<FormInputs>();
|
||||||
const [error, setError] = useState<string | undefined>(undefined);
|
const [error, setError] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
|
@ -37,6 +38,8 @@ export function ModifyAccountModal({ onClose, field }: Props) {
|
||||||
new_email,
|
new_email,
|
||||||
new_password,
|
new_password,
|
||||||
}) => {
|
}) => {
|
||||||
|
setProcessing(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (field === "email") {
|
if (field === "email") {
|
||||||
await client.req("PATCH", "/auth/account/change/email", {
|
await client.req("PATCH", "/auth/account/change/email", {
|
||||||
|
@ -59,6 +62,7 @@ export function ModifyAccountModal({ onClose, field }: Props) {
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(takeError(err));
|
setError(takeError(err));
|
||||||
|
setProcessing(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -67,6 +71,7 @@ export function ModifyAccountModal({ onClose, field }: Props) {
|
||||||
visible={true}
|
visible={true}
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title={<Text id={`app.special.modals.account.change.${field}`} />}
|
title={<Text id={`app.special.modals.account.change.${field}`} />}
|
||||||
|
disabled={processing}
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
confirmation: true,
|
confirmation: true,
|
||||||
|
|
|
@ -193,7 +193,7 @@ export const Account = observer(() => {
|
||||||
<CategoryButton
|
<CategoryButton
|
||||||
icon={<Trash size={24} color="var(--error)" />}
|
icon={<Trash size={24} color="var(--error)" />}
|
||||||
description={
|
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
|
hover
|
||||||
action="external">
|
action="external">
|
||||||
|
|
Loading…
Reference in a new issue