Merge pull request #2526 from BlueWallet/ccfix

FIX: Conf number reflects correct number.
This commit is contained in:
GLaDOS 2021-01-30 06:00:18 +00:00 committed by GitHub
commit f697386785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 12 deletions

View File

@ -2,6 +2,7 @@
import { useAsyncStorage } from '@react-native-async-storage/async-storage';
import React, { createContext, useEffect, useState } from 'react';
import { AppStorage } from '../class';
import { FiatUnit } from '../models/fiatUnit';
const BlueApp = require('../BlueApp');
const BlueElectrum = require('./BlueElectrum');
@ -15,7 +16,7 @@ export const BlueStorageProvider = ({ children }) => {
const [selectedWallet, setSelectedWallet] = useState('');
const [walletTransactionUpdateStatus, setWalletTransactionUpdateStatus] = useState(WalletTransactionsStatus.NONE);
const [walletsInitialized, setWalletsInitialized] = useState(false);
const [preferredFiatCurrency, _setPreferredFiatCurrency] = useState();
const [preferredFiatCurrency, _setPreferredFiatCurrency] = useState(FiatUnit.USD);
const [language, _setLanguage] = useState();
const getPreferredCurrencyAsyncStorage = useAsyncStorage(AppStorage.PREFERRED_CURRENCY).getItem;
const getLanguageAsyncStorage = useAsyncStorage(AppStorage.LANG).getItem;

View File

@ -695,7 +695,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
u.txid = u.txId;
u.amount = u.value;
u.wif = this._getWifForAddress(u.address);
u.confirmations = u.height ? 1 : 0;
if (!u.confirmations && u.height) u.confirmations = BlueElectrum.estimateCurrentBlockheight() - u.height;
}
this.utxo = this.utxo.sort((a, b) => a.amount - b.amount);

View File

@ -34,19 +34,20 @@ const styles = StyleSheet.create({
},
});
const CoinsSelected = ({ number, onClose }) => (
<View style={styles.root}>
const CoinsSelected = ({ number, onContainerPress, onClose }) => (
<TouchableOpacity style={styles.root} onPress={onContainerPress}>
<View style={styles.labelContainer}>
<Text style={styles.labelText}>{loc.formatString(loc.cc.coins_selected, { number })}</Text>
</View>
<TouchableOpacity style={styles.buttonContainer} onPress={onClose}>
<Avatar rounded containerStyle={[styles.ball]} icon={{ name: 'close', size: 22, type: 'ionicons', color: 'white' }} />
</TouchableOpacity>
</View>
</TouchableOpacity>
);
CoinsSelected.propTypes = {
number: PropTypes.number.isRequired,
onContainerPress: PropTypes.func.isRequired,
onClose: PropTypes.func.isRequired,
};

View File

@ -542,7 +542,7 @@
"header": "Coin Control",
"use_coin": "Use Coin",
"use_coins": "Use Coins",
"tip": "Allows you to see, label, freeze or select coins for improved wallet management."
"tip": "Allows you to see, label, freeze or select coins for improved wallet management. You can select multiple coins by tapping on the colored circles."
},
"units": {
"BTC": "BTC",

View File

@ -25,6 +25,7 @@ import navigationStyle from '../../components/navigationStyle';
import BottomModal from '../../components/BottomModal';
import { FContainer, FButton } from '../../components/FloatButtons';
import { BlueStorageContext } from '../../blue_modules/storage-context';
import * as RNLocalize from 'react-native-localize';
// https://levelup.gitconnected.com/debounce-in-javascript-improve-your-applications-performance-5b01855e086
const debounce = (func, wait) => {
@ -79,10 +80,8 @@ const OutputList = ({
const oStyles = StyleSheet.create({
container: { borderBottomColor: colors.lightBorder, backgroundColor: colors.elevated },
containerSelected: {
borderBottomColor: 'rgba(0, 0, 0, 0)',
backgroundColor: colors.ballOutgoingExpired,
borderTopLeftRadius: 10,
borderBottomLeftRadius: 10,
borderBottomColor: 'rgba(0, 0, 0, 0)',
},
avatar: { borderColor: 'white', borderWidth: 1, backgroundColor: color },
amount: { fontWeight: 'bold', color: colors.foregroundColor },
@ -149,15 +148,18 @@ const OutputModal = ({ item: { address, txid, value, vout, confirmations }, bala
tranText: { fontWeight: 'normal', fontSize: 13, color: colors.alternativeTextColor },
memo: { fontSize: 13, marginTop: 3, color: colors.alternativeTextColor },
});
const confirmationsFormatted = new Intl.NumberFormat(RNLocalize.getLocales()[0].languageCode, { maximumSignificantDigits: 3 }).format(
confirmations,
);
return (
<ListItem bottomDivider containerStyle={oStyles.container}>
<Avatar rounded overlayContainerStyle={oStyles.avatar} />
<ListItem.Content>
<ListItem.Title style={oStyles.amount}>
<ListItem.Title numberOfLines={1} adjustsFontSizeToFit style={oStyles.amount}>
{amount}
<View style={oStyles.tranContainer}>
<Text style={oStyles.tranText}>{loc.formatString(loc.transactions.list_conf, { number: confirmations })}</Text>
<Text style={oStyles.tranText}>{loc.formatString(loc.transactions.list_conf, { number: confirmationsFormatted })}</Text>
</View>
</ListItem.Title>
{memo ? (
@ -364,7 +366,10 @@ const CoinControl = () => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); // animate buttons show
setSelected(selected => [...selected, `${p.item.txid}:${p.item.vout}`]);
}}
onDeSelect={() => setSelected(selected => selected.filter(i => i !== `${p.item.txid}:${p.item.vout}`))}
onDeSelect={() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); // animate buttons show
setSelected(selected => selected.filter(i => i !== `${p.item.txid}:${p.item.vout}`));
}}
/>
);
};

View File

@ -1222,6 +1222,7 @@ export default class SendDetails extends Component {
<View style={styles.select}>
<CoinsSelected
number={this.state.utxo.length}
onContainerPress={this.handleCoinControl}
onClose={() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
this.setState({ utxo: null }, this.reCalcTx);