mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-23 15:20:55 +01:00
FIX: add fetchUtxo to coincontrol component
This commit is contained in:
parent
ced1e21cd1
commit
d7b025d5a8
2 changed files with 22 additions and 13 deletions
|
@ -4,6 +4,7 @@ import _debounce from 'lodash/debounce';
|
||||||
import Modal from 'react-native-modal';
|
import Modal from 'react-native-modal';
|
||||||
import { ListItem, Avatar, Badge } from 'react-native-elements';
|
import { ListItem, Avatar, Badge } from 'react-native-elements';
|
||||||
import {
|
import {
|
||||||
|
ActivityIndicator,
|
||||||
FlatList,
|
FlatList,
|
||||||
Keyboard,
|
Keyboard,
|
||||||
KeyboardAvoidingView,
|
KeyboardAvoidingView,
|
||||||
|
@ -12,8 +13,8 @@ import {
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
TouchableWithoutFeedback,
|
TouchableWithoutFeedback,
|
||||||
View,
|
|
||||||
useColorScheme,
|
useColorScheme,
|
||||||
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { useRoute, useTheme, useNavigation } from '@react-navigation/native';
|
import { useRoute, useTheme, useNavigation } from '@react-navigation/native';
|
||||||
|
|
||||||
|
@ -164,12 +165,14 @@ const CoinControl = () => {
|
||||||
const { walletId, onUTXOChoose } = useRoute().params;
|
const { walletId, onUTXOChoose } = useRoute().params;
|
||||||
const { wallets } = useContext(BlueStorageContext);
|
const { wallets } = useContext(BlueStorageContext);
|
||||||
const wallet = wallets.find(w => w.getID() === walletId);
|
const wallet = wallets.find(w => w.getID() === walletId);
|
||||||
const utxo = useMemo(
|
|
||||||
// sort by height ascending, txid , vout ascending
|
// sort by height ascending, txid , vout ascending
|
||||||
() => wallet.getUtxo({ frozen: true }).sort((a, b) => a.height - b.height || a.txid.localeCompare(b.txid) || a.vout - b.vout),
|
const utxo = wallet.getUtxo({ frozen: true }).sort((a, b) => a.height - b.height || a.txid.localeCompare(b.txid) || a.vout - b.vout);
|
||||||
[wallet],
|
|
||||||
);
|
|
||||||
const [output, setOutput] = useState();
|
const [output, setOutput] = useState();
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
wallet.fetchUtxo().then(() => setLoading(false));
|
||||||
|
}, [wallet, setLoading]);
|
||||||
|
|
||||||
const handleChoose = item => setOutput(item);
|
const handleChoose = item => setOutput(item);
|
||||||
|
|
||||||
|
@ -185,6 +188,14 @@ const CoinControl = () => {
|
||||||
return <Output item={p.item} oMemo={memo} frozen={frozen} change={change} onPress={() => handleChoose(p.item)} />;
|
return <Output item={p.item} oMemo={memo} frozen={frozen} change={change} onPress={() => handleChoose(p.item)} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return (
|
||||||
|
<SafeBlueArea style={[styles.root, styles.center, { backgroundColor: colors.elevated }]}>
|
||||||
|
<ActivityIndicator testID="Loading" />
|
||||||
|
</SafeBlueArea>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SafeBlueArea style={[styles.root, { backgroundColor: colors.elevated }]}>
|
<SafeBlueArea style={[styles.root, { backgroundColor: colors.elevated }]}>
|
||||||
{utxo.length === 0 && (
|
{utxo.length === 0 && (
|
||||||
|
@ -216,6 +227,10 @@ const styles = StyleSheet.create({
|
||||||
root: {
|
root: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
|
center: {
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
bottomModal: {
|
bottomModal: {
|
||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
margin: 0,
|
margin: 0,
|
||||||
|
|
|
@ -1087,13 +1087,7 @@ export default class SendDetails extends Component {
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<BlueListItem
|
<BlueListItem title={loc.cc.header} hideChevron component={TouchableOpacity} onPress={this.handleCoinControl} />
|
||||||
title="Coin control"
|
|
||||||
hideChevron
|
|
||||||
// disabled={this.state.addresses.length < 2}
|
|
||||||
component={TouchableOpacity}
|
|
||||||
onPress={this.handleCoinControl}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
</KeyboardAvoidingView>
|
</KeyboardAvoidingView>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
Loading…
Add table
Reference in a new issue