From 9d9c44fd61104e30aa49fbef97f25dfdab5cf192 Mon Sep 17 00:00:00 2001 From: groovecoder Date: Mon, 5 Aug 2024 13:29:34 -0500 Subject: [PATCH] change ternary expressions into if/else blocks for eslint 8 --- .../aliases/CustomAddressGenerationModal.tsx | 8 +++++--- frontend/src/pages/accounts/profile.page.tsx | 11 ++++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/dashboard/aliases/CustomAddressGenerationModal.tsx b/frontend/src/components/dashboard/aliases/CustomAddressGenerationModal.tsx index a19e744935..4752554dcc 100644 --- a/frontend/src/components/dashboard/aliases/CustomAddressGenerationModal.tsx +++ b/frontend/src/components/dashboard/aliases/CustomAddressGenerationModal.tsx @@ -153,9 +153,11 @@ const CustomMaskCreator = (props: CustomMaskCreatorProps) => { event.preventDefault(); const isValid = isAddressValid(address); - isValid - ? onPick(address.toLowerCase(), errorExplainerState.setOpen) - : errorExplainerState.setOpen(!isValid); + if (isValid) { + onPick(address.toLowerCase(), errorExplainerState.setOpen); + } else { + errorExplainerState.setOpen(!isValid); + } }; const onChange: ChangeEventHandler = (event) => { setAddress(event.target.value); diff --git a/frontend/src/pages/accounts/profile.page.tsx b/frontend/src/pages/accounts/profile.page.tsx index aa72f4b67e..e4d7694808 100644 --- a/frontend/src/pages/accounts/profile.page.tsx +++ b/frontend/src/pages/accounts/profile.page.tsx @@ -186,12 +186,13 @@ const Profile: NextPage = () => { setAliasGeneratedState(true); } addonData.sendEvent("aliasListUpdate"); - } catch (error) { + } catch { // TODO: Refactor CustomAddressGenerationModal to remove the setAliasGeneratedState callback, and instead use a try catch block. - setAliasGeneratedState - ? setAliasGeneratedState(false) - : toast(l10n.getString("error-mask-create-failed"), { type: "error" }); - + if (setAliasGeneratedState) { + setAliasGeneratedState(false); + } else { + toast(l10n.getString("error-mask-create-failed"), { type: "error" }); + } // This is so we can catch the error when calling createAlias asynchronously and apply // more logic to handle when generating a mask fails. return Promise.reject("Mask generation failed");