mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 09:50:15 +01:00
FIX: Disable Save button when an async operation is executing.
This commit is contained in:
parent
9fc3c49c9e
commit
638d38070b
@ -182,7 +182,12 @@ strings.formatBalance = (balance, toUnit, withFormatting = false) => {
|
||||
return balance + ' ' + BitcoinUnit.BTC;
|
||||
} else if (toUnit === BitcoinUnit.SATS) {
|
||||
const value = new BigNumber(balance).multipliedBy(100000000);
|
||||
return (balance < 0 ? '-' : '') + (withFormatting ? new Intl.NumberFormat().format(value.toString()).replace(/[^0-9]/g, ' ') : value) + ' ' + BitcoinUnit.SATS;
|
||||
return (
|
||||
(balance < 0 ? '-' : '') +
|
||||
(withFormatting ? new Intl.NumberFormat().format(value.toString()).replace(/[^0-9]/g, ' ') : value) +
|
||||
' ' +
|
||||
BitcoinUnit.SATS
|
||||
);
|
||||
} else if (toUnit === BitcoinUnit.LOCAL_CURRENCY) {
|
||||
return currency.BTCToLocalCurrency(balance);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ export default class WalletDetails extends Component {
|
||||
title: loc.wallets.details.title,
|
||||
headerRight: (
|
||||
<TouchableOpacity
|
||||
disabled={navigation.getParam('isLoading') === true}
|
||||
style={{ marginHorizontal: 16, height: 40, width: 40, justifyContent: 'center', alignItems: 'center' }}
|
||||
onPress={() => {
|
||||
navigation.getParam('saveAction')();
|
||||
@ -34,23 +35,25 @@ export default class WalletDetails extends Component {
|
||||
|
||||
const wallet = props.navigation.getParam('wallet');
|
||||
const address = wallet.getAddress();
|
||||
|
||||
const isLoading = true;
|
||||
this.state = {
|
||||
isLoading: true,
|
||||
isLoading,
|
||||
walletName: wallet.getLabel(),
|
||||
wallet,
|
||||
address,
|
||||
};
|
||||
this.props.navigation.setParams({ saveAction: () => this.setLabel() });
|
||||
this.props.navigation.setParams({ isLoading, saveAction: () => this.setLabel() });
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
this.props.navigation.setParams({ isLoading: false, saveAction: () => this.setLabel() });
|
||||
}
|
||||
|
||||
setLabel() {
|
||||
this.props.navigation.setParams({ isLoading: true });
|
||||
this.setState({ isLoading: true }, () => {
|
||||
this.state.wallet.setLabel(this.state.walletName);
|
||||
BlueApp.saveToDisk();
|
||||
@ -178,6 +181,7 @@ export default class WalletDetails extends Component {
|
||||
{
|
||||
text: loc.wallets.details.yes_delete,
|
||||
onPress: async () => {
|
||||
this.props.navigation.setParams({ isLoading: true });
|
||||
this.setState({ isLoading: true }, async () => {
|
||||
BlueApp.deleteWallet(this.state.wallet);
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', false);
|
||||
@ -207,6 +211,7 @@ export default class WalletDetails extends Component {
|
||||
|
||||
WalletDetails.propTypes = {
|
||||
navigation: PropTypes.shape({
|
||||
getParam: PropTypes.func,
|
||||
state: PropTypes.shape({
|
||||
params: PropTypes.shape({
|
||||
address: PropTypes.string,
|
||||
@ -215,7 +220,6 @@ WalletDetails.propTypes = {
|
||||
}),
|
||||
navigate: PropTypes.func,
|
||||
goBack: PropTypes.func,
|
||||
getParam: PropTypes.func,
|
||||
setParams: PropTypes.func,
|
||||
}),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user