Browse Source

FIX: currency crash

localNotifications
Marcos Rodriguez Vélez 6 years ago
parent
commit
ca203785e6
  1. 1
      android/app/src/main/AndroidManifest.xml
  2. 18
      currency.js
  3. 3
      screen/lnd/scanLndInvoice.js
  4. 16
      screen/send/details.js

1
android/app/src/main/AndroidManifest.xml

@ -25,6 +25,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="bitcoin" />
<data android:scheme="lightning" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

18
currency.js

@ -12,7 +12,6 @@ const STRUCT = {
};
async function updateExchangeRate() {
let preferredFiatCurrency;
try {
preferredFiatCurrency = JSON.parse(await AsyncStorage.getItem(AppStorage.PREFERREDCURRENCY));
if (preferredFiatCurrency === null) {
@ -48,17 +47,16 @@ async function updateExchangeRate() {
async function startUpdater(force = false) {
if (force) {
await AsyncStorage.removeItem(AppStorage.CURRENCY);
try {
preferredFiatCurrency = JSON.parse(await AsyncStorage.getItem(AppStorage.PREFERREDCURRENCY));
if (preferredFiatCurrency === null) {
throw Error();
}
} catch (_error) {
preferredFiatCurrency = FiatUnit.USD;
}
}
lang = await AsyncStorage.getItem(AppStorage.CURRENCY);
preferredFiatCurrency = JSON.parse(await AsyncStorage.getItem(AppStorage.PREFERREDCURRENCY));
try {
preferredFiatCurrency = JSON.parse(await AsyncStorage.getItem(AppStorage.PREFERREDCURRENCY));
if (preferredFiatCurrency === null) {
throw Error();
}
} catch (_error) {
preferredFiatCurrency = FiatUnit.USD;
}
try {
lang = JSON.parse(lang);
} catch (Err) {

3
screen/lnd/scanLndInvoice.js

@ -28,6 +28,7 @@ export default class ScanLndInvoice extends React.Component {
if (!BlueApp.getWallets().some(item => item.type === LightningCustodianWallet.type)) {
alert('Before paying a Lightning invoice, you must first add a Lightning wallet.');
props.navigation.dismiss()
} else {
let fromSecret;
if (props.navigation.state.params.fromSecret) fromSecret = props.navigation.state.params.fromSecret;
@ -77,7 +78,7 @@ export default class ScanLndInvoice extends React.Component {
}, 6000);
if (!this.state.fromWallet) {
alert('Error: cant find source wallet (this should never happen)');
alert('Before paying a Lightning invoice, you must first add a Lightning wallet.');
return this.props.navigation.goBack();
}

16
screen/send/details.js

@ -14,7 +14,7 @@ import {
Text,
} from 'react-native';
import { Icon } from 'react-native-elements';
import { BlueNavigationStyle, BlueButton } from '../../BlueComponents';
import { BlueNavigationStyle, BlueButton, BlueLoading } from '../../BlueComponents';
import PropTypes from 'prop-types';
import Modal from 'react-native-modal';
import NetworkTransactionFees, { NetworkTransactionFee } from '../../models/networkTransactionFees';
@ -41,11 +41,12 @@ export default class SendDetails extends Component {
constructor(props) {
super(props);
this.state = { isLoading: true };
const wallets = BlueApp.getWallets();
if (!BlueApp.getWallets().some(item => item.type !== LightningCustodianWallet.type)) {
alert('Before sending Bitcoins, you must first add a Bitcoin wallet.');
props.navigation.goBack();
props.navigation.dismiss();
} else {
console.log('props.navigation.state.params=', props.navigation.state.params);
let address;
@ -130,7 +131,7 @@ export default class SendDetails extends Component {
fee: response.halfHourFee,
networkTransactionFees: response,
feeSliderValue: response.halfHourFee,
isLoading: false,
isLoading: typeof this.state.fromWallet === 'object',
});
});
if (recommendedFees) {
@ -138,7 +139,7 @@ export default class SendDetails extends Component {
fee: recommendedFees.halfHourFee,
networkTransactionFees: recommendedFees,
feeSliderValue: recommendedFees.halfHourFee,
isLoading: false,
isLoading: typeof this.state.fromWallet === 'object',
});
if (this.props.navigation.state.params.uri) {
@ -478,10 +479,10 @@ export default class SendDetails extends Component {
};
render() {
if (!this.state.fromWallet.getAddress) {
if (this.state.isLoading || typeof this.state.fromWallet === 'undefined') {
return (
<View style={{ flex: 1, paddingTop: 20 }}>
<Text>System error: Source wallet not found (this should never happen)</Text>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<BlueLoading />
</View>
);
}
@ -664,6 +665,7 @@ SendDetails.propTypes = {
navigation: PropTypes.shape({
goBack: PropTypes.function,
navigate: PropTypes.func,
dismiss: PropTypes.func,
state: PropTypes.shape({
params: PropTypes.shape({
address: PropTypes.string,

Loading…
Cancel
Save