From a6b4153aa1bbd97ae2a1e68594f858947f664d69 Mon Sep 17 00:00:00 2001 From: marcosrdz Date: Sat, 13 Mar 2021 22:23:16 -0500 Subject: [PATCH] FIX: Manage funds button would not be visible when switching wallets on large screen devices --- BlueComponents.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/BlueComponents.js b/BlueComponents.js index 8a980a153..07f3c41aa 100644 --- a/BlueComponents.js +++ b/BlueComponents.js @@ -22,6 +22,7 @@ import { TouchableOpacity, TouchableWithoutFeedback, View, + InteractionManager, } from 'react-native'; import Clipboard from '@react-native-clipboard/clipboard'; import LinearGradient from 'react-native-linear-gradient'; @@ -223,8 +224,8 @@ export class BlueWalletNavigationHeader extends Component { onWalletUnitChange: PropTypes.func, }; - static getDerivedStateFromProps(props, state) { - return { wallet: props.wallet, onWalletUnitChange: props.onWalletUnitChange, allowOnchainAddress: state.allowOnchainAddress }; + static getDerivedStateFromProps(props) { + return { wallet: props.wallet, onWalletUnitChange: props.onWalletUnitChange }; } static contextType = BlueStorageContext; @@ -235,7 +236,7 @@ export class BlueWalletNavigationHeader extends Component { this.state = { wallet: props.wallet, walletPreviousPreferredUnit: props.wallet.getPreferredBalanceUnit(), - showManageFundsButton: false, + allowOnchainAddress: false, }; } @@ -243,13 +244,28 @@ export class BlueWalletNavigationHeader extends Component { Clipboard.setString(formatBalance(this.state.wallet.getBalance(), this.state.wallet.getPreferredBalanceUnit()).toString()); }; - componentDidMount() { + componentDidUpdate(prevState) { + InteractionManager.runAfterInteractions(() => { + if (prevState.wallet.getID() !== this.state.wallet.getID() && this.state.wallet.type === LightningCustodianWallet.type) { + this.verifyIfWalletAllowsOnchainAddress(); + } + }); + } + + verifyIfWalletAllowsOnchainAddress = () => { if (this.state.wallet.type === LightningCustodianWallet.type) { this.state.wallet .allowOnchainAddress() .then(value => this.setState({ allowOnchainAddress: value })) - .catch(e => console.log('This Lndhub wallet does not have an onchain address API.')); + .catch(e => { + console.log('This Lndhub wallet does not have an onchain address API.'); + this.setState({ allowOnchainAddress: false }); + }); } + }; + + componentDidMount() { + this.verifyIfWalletAllowsOnchainAddress(); } handleBalanceVisibility = async _item => {