From 714078eddfada43531a4caba0a4c9b0540da7eea Mon Sep 17 00:00:00 2001 From: Palm Date: Mon, 18 Mar 2024 23:00:20 +0700 Subject: [PATCH] fix: double popups at the same time --- src/ui/settings/pages/General.tsx | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/ui/settings/pages/General.tsx b/src/ui/settings/pages/General.tsx index c3f5e41a..0c737eb4 100644 --- a/src/ui/settings/pages/General.tsx +++ b/src/ui/settings/pages/General.tsx @@ -184,6 +184,9 @@ export default function General() { } value={settings.developmentBuildEnabled} onValueChange={(v: boolean) => { + const callback = () => + setDevelopmentBuildEnabled(v).then(showReloadRequiredAlert); + if (v) showConfirmationAlert({ title: "Use development builds?", @@ -192,19 +195,9 @@ export default function General() { confirmText: "Continue", cancelText: "Nevermind", confirmColor: ButtonColors.RED, - onConfirm: () => setDevelopmentBuildEnabled(v) + onConfirm: callback }); - else setDevelopmentBuildEnabled(v); - - showConfirmationAlert({ - title: "Reload required", - content: - "Changes will only apply next time the app launches or reloads.", - confirmText: "Reload now", - cancelText: "Later", - confirmColor: ButtonColors.PRIMARY, - onConfirm: BundleUpdaterManager.reload - }); + else callback() }} /> @@ -254,3 +247,14 @@ export default function General() { ); } + +const showReloadRequiredAlert = () => + showConfirmationAlert({ + title: "Reload required", + content: + "Changes will only apply next time the app launches or reloads.", + confirmText: "Reload now", + cancelText: "Later", + confirmColor: ButtonColors.PRIMARY, + onConfirm: BundleUpdaterManager.reload + });