ADD: Event listener for wallet unlock

This commit is contained in:
marcosrdz 2020-06-20 20:16:05 -04:00 committed by Overtorment
parent 7c3c015933
commit 71cc1f6836
3 changed files with 13 additions and 13 deletions

21
App.js
View file

@ -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 (
<SafeAreaProvider>
<View style={styles.root}>
<NavigationContainer ref={this.getInitialURLAfterSettingNavigationRef}>
<NavigationContainer ref={navigationRef}>
<Navigation />
</NavigationContainer>
{this.renderClipboardContentModal()}

View file

@ -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'));
};

View file

@ -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;