From 71cc1f6836a939cc7ab10f2b145de5b92f239211 Mon Sep 17 00:00:00 2001 From: marcosrdz Date: Sat, 20 Jun 2020 20:16:05 -0400 Subject: [PATCH] ADD: Event listener for wallet unlock --- App.js | 21 ++++++++------------- UnlockWith.js | 2 ++ events.js | 3 +++ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/App.js b/App.js index b5ba61c34..6c89420bb 100644 --- a/App.js +++ b/App.js @@ -27,6 +27,7 @@ const bitcoinModalString = 'Bitcoin address'; const lightningModalString = 'Lightning Invoice'; const loc = require('./loc'); const BlueApp = require('./BlueApp'); +const EV = require('./events'); export default class App extends React.Component { state = { @@ -34,15 +35,19 @@ export default class App extends React.Component { isClipboardContentModalVisible: false, clipboardContentModalAddressType: bitcoinModalString, clipboardContent: '', - isColdStart: true, }; componentDidMount() { + EV(EV.enum.WALLETS_INITIALIZED, this.addListeners); + } + + addListeners = () => { Linking.addEventListener('url', this.handleOpenURL); AppState.addEventListener('change', this._handleAppStateChange); DeviceEventEmitter.addListener('quickActionShortcut', this.walletQuickActions); + QuickActions.popInitialAction().then(this.popInitialAction); this._handleAppStateChange(undefined); - } + }; popInitialAction = async data => { if (data) { @@ -210,21 +215,11 @@ export default class App extends React.Component { ); }; - getInitialURLAfterSettingNavigationRef = ref => { - if (this.state.isColdStart) { - this.setState({ isColdStart: false }); - navigationRef.current = ref; - QuickActions.popInitialAction().then(this.popInitialAction); - } else { - navigationRef.current = ref; - } - }; - render() { return ( - + {this.renderClipboardContentModal()} diff --git a/UnlockWith.js b/UnlockWith.js index 120712c56..e1ec7e999 100644 --- a/UnlockWith.js +++ b/UnlockWith.js @@ -5,6 +5,7 @@ import Biometric from './class/biometrics'; import { SafeAreaView } from 'react-native-safe-area-context'; import * as NavigationService from './NavigationService'; import { StackActions } from '@react-navigation/native'; +const EV = require('./events'); /** @type {AppStorage} */ const BlueApp = require('./BlueApp'); @@ -65,6 +66,7 @@ export default class UnlockWith extends Component { } successfullyAuthenticated = () => { + EV(EV.enum.WALLETS_INITIALIZED); NavigationService.dispatch(StackActions.replace('WalletsRoot')); }; diff --git a/events.js b/events.js index fa52fc398..2fb9e041c 100644 --- a/events.js +++ b/events.js @@ -37,6 +37,9 @@ EV.enum = { REMOTE_TRANSACTIONS_COUNT_CHANGED: 'REMOTE_TRANSACTIONS_COUNT_CHANGED', // RECEIVE_ADDRESS_CHANGED: 'RECEIVE_ADDRESS_CHANGED', + + // when called, the deep linking listeners are set + WALLETS_INITIALIZED: 'WALLETS_INITIALIZED', }; module.exports = EV;