From ce0749d9e816970093cef0e4e3c9519f030c2041 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 19 Sep 2021 13:47:25 +0100 Subject: [PATCH] Prevent double sending of requests. --- src/context/intermediate/popovers/ModifyAccount.tsx | 5 +++++ src/pages/settings/panes/Account.tsx | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/context/intermediate/popovers/ModifyAccount.tsx b/src/context/intermediate/popovers/ModifyAccount.tsx index 4c2e68a8..509f315f 100644 --- a/src/context/intermediate/popovers/ModifyAccount.tsx +++ b/src/context/intermediate/popovers/ModifyAccount.tsx @@ -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(); const [error, setError] = useState(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={} + disabled={processing} actions={[ { confirmation: true, diff --git a/src/pages/settings/panes/Account.tsx b/src/pages/settings/panes/Account.tsx index 194dfe00..06553a48 100644 --- a/src/pages/settings/panes/Account.tsx +++ b/src/pages/settings/panes/Account.tsx @@ -193,7 +193,7 @@ export const Account = observer(() => { } 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">