From a59dda61d4600ef0a07fb6387fa70e96ea3f5122 Mon Sep 17 00:00:00 2001 From: marcosrdz Date: Sun, 15 Nov 2020 13:19:55 -0500 Subject: [PATCH] FIX: Dim nonselected wallets on additional screens --- screen/lnd/lndCreateInvoice.js | 6 +++++- screen/lnd/lndViewInvoice.js | 1 + screen/send/details.js | 4 +++- screen/transactions/transactionStatus.js | 2 ++ screen/wallets/details.js | 7 ++++++- screen/wallets/list.js | 2 ++ screen/wallets/transactions.js | 1 - 7 files changed, 19 insertions(+), 4 deletions(-) diff --git a/screen/lnd/lndCreateInvoice.js b/screen/lnd/lndCreateInvoice.js index e4590d493..8e7a878ce 100644 --- a/screen/lnd/lndCreateInvoice.js +++ b/screen/lnd/lndCreateInvoice.js @@ -177,6 +177,7 @@ export default class LNDCreateInvoice extends Component { componentDidMount() { console.log('lnd/lndCreateInvoice mounted'); + this.context.setSelectedWallet(this.state.fromWallet.getID()); if (this.state.fromWallet.getUserHasSavedExport()) { this.renderReceiveDetails(); } else { @@ -411,7 +412,10 @@ export default class LNDCreateInvoice extends Component { }; onWalletSelect = wallet => { - this.setState({ fromWallet: wallet }, () => this.props.navigation.pop()); + this.setState({ fromWallet: wallet }, () => { + this.context.setSelectedWallet(wallet.getID()); + this.props.navigation.pop(); + }); }; render() { diff --git a/screen/lnd/lndViewInvoice.js b/screen/lnd/lndViewInvoice.js index 93a79c827..6e350c3fd 100644 --- a/screen/lnd/lndViewInvoice.js +++ b/screen/lnd/lndViewInvoice.js @@ -137,6 +137,7 @@ export default class LNDViewInvoice extends Component { } componentDidMount() { + this.context.setSelectedWallet(this.state.fromWallet.getID()); console.log('LNDViewInvoice - componentDidMount'); this.fetchInvoiceInterval = setInterval(async () => { if (this.state.isFetchingInvoices) { diff --git a/screen/send/details.js b/screen/send/details.js index ed58baaba..4a1469257 100644 --- a/screen/send/details.js +++ b/screen/send/details.js @@ -330,8 +330,9 @@ export default class SendDetails extends Component { }; async componentDidMount() { - this.renderNavigationHeader(); console.log('send/details - componentDidMount'); + this.renderNavigationHeader(); + this.context.setSelectedWallet(this.state.fromWallet.getID()); /** @type {BitcoinTransaction[]} */ const addresses = []; let initialMemo = ''; @@ -673,6 +674,7 @@ export default class SendDetails extends Component { const changeWallet = () => { this.setState({ fromWallet: wallet }, () => { this.renderNavigationHeader(); + this.context.setSelectedWallet(wallet.getID()); this.props.navigation.pop(); }); }; diff --git a/screen/transactions/transactionStatus.js b/screen/transactions/transactionStatus.js index 252e542c2..646c4c7d4 100644 --- a/screen/transactions/transactionStatus.js +++ b/screen/transactions/transactionStatus.js @@ -158,6 +158,7 @@ export default class TransactionsStatus extends Component { if (t.hash === hash) { console.log('tx', hash, 'belongs to', w.getLabel()); wallet = w; + break; } } } @@ -194,6 +195,7 @@ export default class TransactionsStatus extends Component { isRBFCancelPossible: buttonStatus.notPossible, }); } + this.context.setSelectedWallet(this.state.wallet.getID()); } async checkPossibilityOfCPFP() { diff --git a/screen/wallets/details.js b/screen/wallets/details.js index 6d7cc1535..5e3316529 100644 --- a/screen/wallets/details.js +++ b/screen/wallets/details.js @@ -94,7 +94,7 @@ const styles = StyleSheet.create({ }); const WalletDetails = () => { - const { saveToDisk, wallets, deleteWallet } = useContext(BlueStorageContext); + const { saveToDisk, wallets, deleteWallet, setSelectedWallet } = useContext(BlueStorageContext); const { walletID } = useRoute().params; const [isLoading, setIsLoading] = useState(true); const [backdoorPressed, setBackdoorPressed] = useState(0); @@ -155,6 +155,11 @@ const WalletDetails = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + useEffect(() => { + setSelectedWallet(walletID); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [walletID]); + const presentWalletHasBalanceAlert = useCallback(async () => { ReactNativeHapticFeedback.trigger('notificationWarning', { ignoreAndroidSystemSettings: false }); try { diff --git a/screen/wallets/list.js b/screen/wallets/list.js index 5334a3db2..b39417f1c 100644 --- a/screen/wallets/list.js +++ b/screen/wallets/list.js @@ -45,6 +45,7 @@ const WalletsList = () => { refreshAllWalletTransactions, newWalletAdded, setNewWalletAdded, + setSelectedWallet, } = useContext(BlueStorageContext); const { width } = useWindowDimensions(); const { colors, scanImage } = useTheme(); @@ -83,6 +84,7 @@ const WalletsList = () => { useFocusEffect( useCallback(() => { verifyBalance(); + setSelectedWallet(''); // eslint-disable-next-line react-hooks/exhaustive-deps }, []), ); diff --git a/screen/wallets/transactions.js b/screen/wallets/transactions.js index 76e7d76e6..2e451a874 100644 --- a/screen/wallets/transactions.js +++ b/screen/wallets/transactions.js @@ -110,7 +110,6 @@ const WalletTransactions = () => { const interval = setInterval(() => setTimeElapsed(prev => prev + 1), 60000); return () => { clearInterval(interval); - setSelectedWallet(''); }; // eslint-disable-next-line react-hooks/exhaustive-deps }, []);