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

View File

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

View File

@ -204,7 +204,6 @@ export default class WalletTransactions extends Component {
async onWillBlur() {
StatusBar.setBarStyle('dark-content');
await BlueApp.saveToDisk();
}
componentWillUnmount() {
@ -227,7 +226,14 @@ export default class WalletTransactions extends Component {
onWillBlur={() => this.onWillBlur()}
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' }}>
{this.state.wallet.type === LightningCustodianWallet.type && (
<TouchableOpacity