mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 15:04:50 +01:00
ADD: If wallet was previously imported, throw an alert.
This commit is contained in:
parent
59f4a25b4b
commit
912d8808cc
6 changed files with 37 additions and 30 deletions
|
@ -33,7 +33,7 @@
|
|||
</dict>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>179</string>
|
||||
<string>180</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
|
|
|
@ -36,6 +36,7 @@ export default class LNDCreateInvoice extends Component {
|
|||
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
|
||||
this.props.navigation.navigate('LNDViewInvoice', {
|
||||
invoice: invoiceRequest,
|
||||
fromWallet: this.state.fromWallet,
|
||||
});
|
||||
}
|
||||
this.setState({ isLoading: false });
|
||||
|
|
|
@ -24,30 +24,33 @@ export default class LNDViewInvoice extends Component {
|
|||
this.state = {
|
||||
invoice,
|
||||
fromWallet,
|
||||
isLoading: true,
|
||||
addressText: typeof invoice === 'object' ? invoice.payment_request : invoice,
|
||||
};
|
||||
this.fetchInvoiceInterval = undefined;
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
if (!this.state.invoice.isLoading) {
|
||||
this.fetchInvoiceInterval = setInterval(async () => {
|
||||
const userInvoices = JSON.stringify(await this.state.fromWallet.getUserInvoices());
|
||||
const updatedUserInvoice = JSON.parse(userInvoices).filter(
|
||||
invoice => invoice.payment_request === this.state.invoice.payment_request,
|
||||
)[0];
|
||||
this.setState({ invoice: updatedUserInvoice });
|
||||
if (updatedUserInvoice.ispaid) {
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
|
||||
clearInterval(this.fetchInvoiceInterval);
|
||||
EV(EV.enum.TRANSACTIONS_COUNT_CHANGED);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
this.fetchInvoiceInterval = setInterval(async () => {
|
||||
const userInvoices = JSON.stringify(await this.state.fromWallet.getUserInvoices());
|
||||
const updatedUserInvoice = JSON.parse(userInvoices).filter(invoice =>
|
||||
typeof this.state.invoice === 'object'
|
||||
? invoice.payment_request === this.state.invoice.payment_request
|
||||
: invoice.payment_request === this.state.invoice,
|
||||
)[0];
|
||||
this.setState({ invoice: updatedUserInvoice, isLoading: false });
|
||||
if (updatedUserInvoice.ispaid) {
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
|
||||
clearInterval(this.fetchInvoiceInterval);
|
||||
this.fetchInvoiceInterval = undefined;
|
||||
EV(EV.enum.TRANSACTIONS_COUNT_CHANGED);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearInterval(this.fetchInvoiceInterval);
|
||||
this.fetchInvoiceInterval = undefined;
|
||||
}
|
||||
|
||||
copyToClipboard = () => {
|
||||
|
|
|
@ -29,7 +29,6 @@ export default class WalletExport extends Component {
|
|||
let address = props.navigation.state.params.address;
|
||||
let secret = props.navigation.state.params.secret;
|
||||
let wallet;
|
||||
|
||||
for (let w of BlueApp.getWallets()) {
|
||||
if ((address && w.getAddress() === address) || w.getSecret() === secret) {
|
||||
// found our wallet
|
||||
|
|
|
@ -50,14 +50,18 @@ export default class WalletsImport extends Component {
|
|||
}
|
||||
|
||||
async _saveWallet(w) {
|
||||
alert(loc.wallets.import.success);
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
|
||||
w.setLabel(loc.wallets.import.imported + ' ' + w.getTypeReadable());
|
||||
BlueApp.wallets.push(w);
|
||||
await BlueApp.saveToDisk();
|
||||
EV(EV.enum.WALLETS_COUNT_CHANGED);
|
||||
A(A.ENUM.CREATED_WALLET);
|
||||
this.props.navigation.dismiss();
|
||||
if (BlueApp.getWallets().some(wallet => wallet.getSecret() === w.secret)) {
|
||||
alert('This wallet has been previously imported.');
|
||||
} else {
|
||||
alert(loc.wallets.import.success);
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
|
||||
w.setLabel(loc.wallets.import.imported + ' ' + w.getTypeReadable());
|
||||
BlueApp.wallets.push(w);
|
||||
await BlueApp.saveToDisk();
|
||||
EV(EV.enum.WALLETS_COUNT_CHANGED);
|
||||
A(A.ENUM.CREATED_WALLET);
|
||||
this.props.navigation.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
async importMnemonic(text) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Dimensions, Platform, ActivityIndicator, View, Clipboard, Animated, TouchableOpacity } from 'react-native';
|
||||
import { QRCode as QRSlow } from 'react-native-custom-qr-codes';
|
||||
import { BlueSpacing40, SafeBlueArea, BlueCard, BlueText, BlueHeaderDefaultSub } from '../../BlueComponents';
|
||||
import { BlueSpacing40, SafeBlueArea, BlueCard, BlueText, BlueNavigationStyle } from '../../BlueComponents';
|
||||
import PropTypes from 'prop-types';
|
||||
const QRFast = require('react-native-qrcode');
|
||||
/** @type {AppStorage} */
|
||||
|
@ -17,11 +17,11 @@ if (aspectRatio > 1.6) {
|
|||
}
|
||||
|
||||
export default class WalletXpub extends Component {
|
||||
static navigationOptions = {
|
||||
header: ({ navigation }) => {
|
||||
return <BlueHeaderDefaultSub leftText={loc.wallets.xpub.title} onClose={() => navigation.goBack(null)} />;
|
||||
},
|
||||
};
|
||||
static navigationOptions = ({ navigation }) => ({
|
||||
...BlueNavigationStyle(navigation, true),
|
||||
title: loc.wallets.xpub.title,
|
||||
headerLeft: null,
|
||||
});
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
|
Loading…
Add table
Reference in a new issue