diff --git a/screen/send/coinControl.js b/screen/send/coinControl.js index 5b95a046f..9dca1b409 100644 --- a/screen/send/coinControl.js +++ b/screen/send/coinControl.js @@ -4,6 +4,7 @@ import _debounce from 'lodash/debounce'; import Modal from 'react-native-modal'; import { ListItem, Avatar, Badge } from 'react-native-elements'; import { + ActivityIndicator, FlatList, Keyboard, KeyboardAvoidingView, @@ -12,8 +13,8 @@ import { Text, TextInput, TouchableWithoutFeedback, - View, useColorScheme, + View, } from 'react-native'; import { useRoute, useTheme, useNavigation } from '@react-navigation/native'; @@ -164,12 +165,14 @@ const CoinControl = () => { const { walletId, onUTXOChoose } = useRoute().params; const { wallets } = useContext(BlueStorageContext); const wallet = wallets.find(w => w.getID() === walletId); - const utxo = useMemo( - // 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), - [wallet], - ); + // sort by height ascending, txid , vout ascending + const utxo = wallet.getUtxo({ frozen: true }).sort((a, b) => a.height - b.height || a.txid.localeCompare(b.txid) || a.vout - b.vout); const [output, setOutput] = useState(); + const [loading, setLoading] = useState(true); + + useEffect(() => { + wallet.fetchUtxo().then(() => setLoading(false)); + }, [wallet, setLoading]); const handleChoose = item => setOutput(item); @@ -185,6 +188,14 @@ const CoinControl = () => { return handleChoose(p.item)} />; }; + if (loading) { + return ( + + + + ); + } + return ( {utxo.length === 0 && ( @@ -216,6 +227,10 @@ const styles = StyleSheet.create({ root: { flex: 1, }, + center: { + justifyContent: 'center', + alignItems: 'center', + }, bottomModal: { justifyContent: 'flex-end', margin: 0, diff --git a/screen/send/details.js b/screen/send/details.js index 4e5ceded9..66d732baa 100644 --- a/screen/send/details.js +++ b/screen/send/details.js @@ -1087,13 +1087,7 @@ export default class SendDetails extends Component { /> )} - +