REF: use route params walletID, instead of fromWallet for SendDetails screen

This commit is contained in:
Ivan Vershigora 2021-03-09 15:59:36 +03:00
parent af4b653123
commit 96efec19d8
4 changed files with 9 additions and 11 deletions

View File

@ -47,7 +47,6 @@ class DeeplinkSchemaMatch {
if (context.wallets.length >= 0) {
const wallet = context.wallets[0];
const action = event.url.split('widget?action=')[1];
const secret = wallet.getSecret();
if (wallet.chain === Chain.ONCHAIN) {
if (action === 'openSend') {
completionHandler([
@ -55,7 +54,7 @@ class DeeplinkSchemaMatch {
{
screen: 'SendDetails',
params: {
secret,
walletID: wallet.getID(),
},
},
]);
@ -322,7 +321,7 @@ class DeeplinkSchemaMatch {
screen: 'SendDetails',
params: {
uri: uri.bitcoin,
fromWallet: wallet,
walletID: wallet.getID(),
},
},
];

View File

@ -265,9 +265,9 @@ const CoinControl = () => {
const { colors } = useTheme();
const navigation = useNavigation();
const { width } = useWindowDimensions();
const { walletId, onUTXOChoose } = useRoute().params;
const { walletID, onUTXOChoose } = useRoute().params;
const { wallets, saveToDisk, sleep } = useContext(BlueStorageContext);
const wallet = wallets.find(w => w.getID() === walletId);
const wallet = wallets.find(w => w.getID() === walletID);
// sort by height ascending, txid , vout ascending
const utxo = wallet.getUtxo(true).sort((a, b) => a.height - b.height || a.txid.localeCompare(b.txid) || a.vout - b.vout);
const [output, setOutput] = useState();

View File

@ -55,7 +55,7 @@ const btcAddressRx = /^[a-zA-Z0-9]{26,35}$/;
const SendDetails = () => {
const { wallets, setSelectedWallet, sleep, txMetadata, saveToDisk } = useContext(BlueStorageContext);
const navigation = useNavigation();
const { name, params: routeParams } = useRoute(); // FIXME refactor to use walletID
const { name, params: routeParams } = useRoute();
const scrollView = useRef();
const { colors } = useTheme();
@ -126,7 +126,7 @@ const SendDetails = () => {
navigation.goBack();
return;
}
const wallet = routeParams.fromWallet || suitable[0];
const wallet = (routeParams.walletID && wallets.find(w => w.getID() === routeParams.walletID)) || suitable[0];
setWallet(wallet);
setFeeUnit(wallet.getPreferredBalanceUnit());
setAmountUnit(wallet.preferredBalanceUnit); // default for whole screen
@ -778,7 +778,7 @@ const SendDetails = () => {
const handleCoinControl = () => {
setOptionsVisible(false);
navigation.navigate('CoinControl', {
walletId: wallet.getID(),
walletID: wallet.getID(),
onUTXOChoose: utxo => setUtxo(utxo),
});
};

View File

@ -422,7 +422,7 @@ const WalletTransactions = () => {
params: {
memo: loc.lnd.refill_lnd_balance,
address: toAddress,
fromWallet: selectedWallet,
walletID: selectedWallet.getID(),
},
});
}
@ -431,7 +431,7 @@ const WalletTransactions = () => {
navigate('SendDetailsRoot', {
screen: 'SendDetails',
params: {
fromWallet: wallet,
walletID: wallet.getID(),
},
});
};
@ -444,7 +444,6 @@ const WalletTransactions = () => {
const params = {
walletID: wallet.getID(),
uri: ret.data ? ret.data : ret,
fromWallet: wallet,
};
if (wallet.chain === Chain.ONCHAIN) {
navigate('SendDetailsRoot', { screen: 'SendDetails', params });