mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-04 04:13:49 +01:00
ADD: Event listener for wallet unlock
This commit is contained in:
parent
7c3c015933
commit
71cc1f6836
3 changed files with 13 additions and 13 deletions
21
App.js
21
App.js
|
@ -27,6 +27,7 @@ const bitcoinModalString = 'Bitcoin address';
|
||||||
const lightningModalString = 'Lightning Invoice';
|
const lightningModalString = 'Lightning Invoice';
|
||||||
const loc = require('./loc');
|
const loc = require('./loc');
|
||||||
const BlueApp = require('./BlueApp');
|
const BlueApp = require('./BlueApp');
|
||||||
|
const EV = require('./events');
|
||||||
|
|
||||||
export default class App extends React.Component {
|
export default class App extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
|
@ -34,15 +35,19 @@ export default class App extends React.Component {
|
||||||
isClipboardContentModalVisible: false,
|
isClipboardContentModalVisible: false,
|
||||||
clipboardContentModalAddressType: bitcoinModalString,
|
clipboardContentModalAddressType: bitcoinModalString,
|
||||||
clipboardContent: '',
|
clipboardContent: '',
|
||||||
isColdStart: true,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
EV(EV.enum.WALLETS_INITIALIZED, this.addListeners);
|
||||||
|
}
|
||||||
|
|
||||||
|
addListeners = () => {
|
||||||
Linking.addEventListener('url', this.handleOpenURL);
|
Linking.addEventListener('url', this.handleOpenURL);
|
||||||
AppState.addEventListener('change', this._handleAppStateChange);
|
AppState.addEventListener('change', this._handleAppStateChange);
|
||||||
DeviceEventEmitter.addListener('quickActionShortcut', this.walletQuickActions);
|
DeviceEventEmitter.addListener('quickActionShortcut', this.walletQuickActions);
|
||||||
|
QuickActions.popInitialAction().then(this.popInitialAction);
|
||||||
this._handleAppStateChange(undefined);
|
this._handleAppStateChange(undefined);
|
||||||
}
|
};
|
||||||
|
|
||||||
popInitialAction = async data => {
|
popInitialAction = async data => {
|
||||||
if (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() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<SafeAreaProvider>
|
<SafeAreaProvider>
|
||||||
<View style={styles.root}>
|
<View style={styles.root}>
|
||||||
<NavigationContainer ref={this.getInitialURLAfterSettingNavigationRef}>
|
<NavigationContainer ref={navigationRef}>
|
||||||
<Navigation />
|
<Navigation />
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
{this.renderClipboardContentModal()}
|
{this.renderClipboardContentModal()}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import Biometric from './class/biometrics';
|
||||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||||
import * as NavigationService from './NavigationService';
|
import * as NavigationService from './NavigationService';
|
||||||
import { StackActions } from '@react-navigation/native';
|
import { StackActions } from '@react-navigation/native';
|
||||||
|
const EV = require('./events');
|
||||||
/** @type {AppStorage} */
|
/** @type {AppStorage} */
|
||||||
|
|
||||||
const BlueApp = require('./BlueApp');
|
const BlueApp = require('./BlueApp');
|
||||||
|
@ -65,6 +66,7 @@ export default class UnlockWith extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
successfullyAuthenticated = () => {
|
successfullyAuthenticated = () => {
|
||||||
|
EV(EV.enum.WALLETS_INITIALIZED);
|
||||||
NavigationService.dispatch(StackActions.replace('WalletsRoot'));
|
NavigationService.dispatch(StackActions.replace('WalletsRoot'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,9 @@ EV.enum = {
|
||||||
REMOTE_TRANSACTIONS_COUNT_CHANGED: 'REMOTE_TRANSACTIONS_COUNT_CHANGED',
|
REMOTE_TRANSACTIONS_COUNT_CHANGED: 'REMOTE_TRANSACTIONS_COUNT_CHANGED',
|
||||||
|
|
||||||
// RECEIVE_ADDRESS_CHANGED: 'RECEIVE_ADDRESS_CHANGED',
|
// RECEIVE_ADDRESS_CHANGED: 'RECEIVE_ADDRESS_CHANGED',
|
||||||
|
|
||||||
|
// when called, the deep linking listeners are set
|
||||||
|
WALLETS_INITIALIZED: 'WALLETS_INITIALIZED',
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = EV;
|
module.exports = EV;
|
||||||
|
|
Loading…
Add table
Reference in a new issue