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