FIX: Save unit change fixed

This commit is contained in:
Marcos Rodriguez 2019-08-04 02:42:05 -04:00 committed by Overtorment
parent 1a4f820c63
commit a5455d2549
3 changed files with 21 additions and 9 deletions

View File

@ -163,10 +163,11 @@ export class LightningButton extends Component {
export class BlueWalletNavigationHeader extends Component { export class BlueWalletNavigationHeader extends Component {
static propTypes = { static propTypes = {
wallet: PropTypes.shape().isRequired, wallet: PropTypes.shape().isRequired,
onWalletUnitChange: PropTypes.func,
}; };
static getDerivedStateFromProps(props, _state) { static getDerivedStateFromProps(props, _state) {
return { wallet: props.wallet }; return { wallet: props.wallet, onWalletUnitChange: props.onWalletUnitChange };
} }
constructor(props) { constructor(props) {
@ -230,7 +231,9 @@ export class BlueWalletNavigationHeader extends Component {
walletPreviousPreferredUnit = BitcoinUnit.BTC; walletPreviousPreferredUnit = BitcoinUnit.BTC;
} }
this.setState({ wallet, walletPreviousPreferredUnit: walletPreviousPreferredUnit }); this.setState({ wallet, walletPreviousPreferredUnit: walletPreviousPreferredUnit }, () => {
this.props.onWalletUnitChange(wallet);
});
} }
render() { render() {
@ -241,8 +244,7 @@ export class BlueWalletNavigationHeader extends Component {
> >
<Image <Image
source={ source={
(LightningCustodianWallet.type === this.state.wallet.type && require('./img/lnd-shape.png')) || (LightningCustodianWallet.type === this.state.wallet.type && require('./img/lnd-shape.png')) || require('./img/btc-shape.png')
require('./img/btc-shape.png')
} }
style={{ style={{
width: 99, width: 99,

View File

@ -5,9 +5,13 @@ amplitude.getInstance().init('8b7cf19e8eea3cdcf16340f5fbf16330', null, {
useNativeDeviceInfo: true, useNativeDeviceInfo: true,
}); });
let A = event => { let A = async event => {
amplitude.getInstance().logEvent(event); amplitude.getInstance().logEvent(event, {});
Analytics.trackEvent(event); try {
Analytics.trackEvent(event);
} catch (err) {
console.log(err);
}
}; };
A.ENUM = { A.ENUM = {

View File

@ -204,7 +204,6 @@ export default class WalletTransactions extends Component {
async onWillBlur() { async onWillBlur() {
StatusBar.setBarStyle('dark-content'); StatusBar.setBarStyle('dark-content');
await BlueApp.saveToDisk();
} }
componentWillUnmount() { componentWillUnmount() {
@ -227,7 +226,14 @@ export default class WalletTransactions extends Component {
onWillBlur={() => this.onWillBlur()} onWillBlur={() => this.onWillBlur()}
onDidFocus={() => this.props.navigation.setParams({ isLoading: false })} onDidFocus={() => this.props.navigation.setParams({ isLoading: false })}
/> />
<BlueWalletNavigationHeader wallet={this.state.wallet} /> <BlueWalletNavigationHeader
wallet={this.state.wallet}
onWalletUnitChange={wallet =>
InteractionManager.runAfterInteractions(async () => {
this.setState({ wallet }, () => BlueApp.saveToDisk());
})
}
/>
<View style={{ flex: 1, backgroundColor: '#FFFFFF' }}> <View style={{ flex: 1, backgroundColor: '#FFFFFF' }}>
{this.state.wallet.type === LightningCustodianWallet.type && ( {this.state.wallet.type === LightningCustodianWallet.type && (
<TouchableOpacity <TouchableOpacity