From 614e10ab3a7a3736e1b9f608d3daac02ef4411b6 Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sat, 21 Oct 2023 19:01:24 -0400 Subject: [PATCH] Update add.js --- screen/wallets/add.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/screen/wallets/add.js b/screen/wallets/add.js index 1109c10ed..0522f1186 100644 --- a/screen/wallets/add.js +++ b/screen/wallets/add.js @@ -32,6 +32,7 @@ import loc from '../../loc'; import { BlueStorageContext } from '../../blue_modules/storage-context'; import { LdkButton } from '../../components/LdkButton'; import alert from '../../components/Alert'; +import useAsyncPromise from '../../class/useAsyncPromise'; const BlueApp = require('../../BlueApp'); const AppStorage = BlueApp.AppStorage; const A = require('../../blue_modules/analytics'); @@ -51,7 +52,7 @@ const WalletsAdd = () => { const [walletBaseURI, setWalletBaseURI] = useState(''); const [selectedIndex, setSelectedIndex] = useState(0); const [label, setLabel] = useState(''); - const [isAdvancedOptionsEnabled, setIsAdvancedOptionsEnabled] = useState(false); + const isAdvancedOptionsEnabled = useAsyncPromise(isAdvancedModeEnabled()); const [selectedWalletType, setSelectedWalletType] = useState(false); const [backdoorPressed, setBackdoorPressed] = useState(1); const { navigate, goBack, setOptions } = useNavigation(); @@ -82,11 +83,8 @@ const WalletsAdd = () => { useEffect(() => { AsyncStorage.getItem(AppStorage.LNDHUB) .then(url => setWalletBaseURI(url)) - .catch(() => setWalletBaseURI('')); - isAdvancedModeEnabled() - .then(setIsAdvancedOptionsEnabled) + .catch(() => setWalletBaseURI('')) .finally(() => setIsLoading(false)); - // eslint-disable-next-line react-hooks/exhaustive-deps }, [isAdvancedOptionsEnabled]); useEffect(() => { @@ -306,7 +304,7 @@ const WalletsAdd = () => { {(() => { - if (selectedWalletType === ButtonSelected.ONCHAIN && isAdvancedOptionsEnabled) { + if (selectedWalletType === ButtonSelected.ONCHAIN && isAdvancedOptionsEnabled.data) { return ( @@ -361,7 +359,7 @@ const WalletsAdd = () => { ); } })()} - {isAdvancedOptionsEnabled && selectedWalletType === ButtonSelected.ONCHAIN && !isLoading && ( + {isAdvancedOptionsEnabled.data && selectedWalletType === ButtonSelected.ONCHAIN && !isLoading && ( )}