better "insufficient funds" message"
This commit is contained in:
parent
b45c2cfab0
commit
9fddde615a
3 changed files with 35 additions and 21 deletions
|
|
@ -58,9 +58,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
};
|
||||
|
||||
function setNoWallet(msg) {
|
||||
function setNoWallet(msg, criticalError) {
|
||||
$scope.wallet = null;
|
||||
$scope.noWalletMessage = msg;
|
||||
$scope.criticalError = criticalError;
|
||||
$log.warn('Not ready to make the payment:' + msg);
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
|
|
@ -81,7 +82,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
});
|
||||
|
||||
if (!$scope.wallets || !$scope.wallets.length) {
|
||||
setNoWallet(gettextCatalog.getString('No wallets available'));
|
||||
setNoWallet(gettextCatalog.getString('No wallets available'), true);
|
||||
return cb();
|
||||
}
|
||||
|
||||
|
|
@ -110,7 +111,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
return cb('Could not update any wallet');
|
||||
|
||||
if (lodash.isEmpty(filteredWallets)) {
|
||||
setNoWallet(gettextCatalog.getString('Insufficient funds'));
|
||||
setNoWallet(gettextCatalog.getString('Insufficient funds'), true);
|
||||
}
|
||||
$scope.wallets = lodash.clone(filteredWallets);
|
||||
return cb();
|
||||
|
|
|
|||
|
|
@ -84,14 +84,9 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
|
||||
data = sanitizeUri(data);
|
||||
|
||||
// Bitcoin or Bitcoin Cash URL
|
||||
if ((/^bitcoin(cash)?:/).exec(data)) {
|
||||
var coin = 'btc';
|
||||
if ((/^bitcoincash:/).exec(data)) {
|
||||
coin = 'bch';
|
||||
data = data.replace(/bitcoincash:/, 'bitcoin:');
|
||||
}
|
||||
if (bitcore.URI.isValid(data)) {
|
||||
// Bitcoin URL
|
||||
if (bitcore.URI.isValid(data)) {
|
||||
var coin = 'btc';
|
||||
var parsed = new bitcore.URI(data);
|
||||
|
||||
var addr = parsed.address ? parsed.address.toString() : '';
|
||||
|
|
@ -111,11 +106,30 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
}
|
||||
return true;
|
||||
|
||||
} else {
|
||||
$log.error('Invalid Bitcoin URL');
|
||||
return false;
|
||||
}
|
||||
} else if (bitcoreCash.URI.isValid(data)) {
|
||||
var coin = 'bch';
|
||||
var parsed = new bitcoreCash.URI(data);
|
||||
|
||||
var addr = parsed.address ? parsed.address.toString() : '';
|
||||
var message = parsed.message;
|
||||
|
||||
var amount = parsed.amount ? parsed.amount : '';
|
||||
|
||||
// paypro not yet supported on cash
|
||||
if (parsed.r) {
|
||||
payproService.getPayProDetails(parsed.r, function(err, details) {
|
||||
if (err) {
|
||||
if (addr && amount)
|
||||
goSend(addr, amount, message, coin);
|
||||
else
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
}
|
||||
handlePayPro(details, coin);
|
||||
});
|
||||
} else {
|
||||
goSend(addr, amount, message, coin);
|
||||
}
|
||||
return true;
|
||||
// Plain URL
|
||||
} else if (/^https?:\/\//.test(data)) {
|
||||
|
||||
|
|
@ -259,9 +273,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
function goToAmountPage(toAddress, coin) {
|
||||
|
|
@ -277,12 +289,13 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
|||
}, 100);
|
||||
}
|
||||
|
||||
function handlePayPro(payProDetails) {
|
||||
function handlePayPro(payProDetails, coin) {
|
||||
var stateParams = {
|
||||
toAmount: payProDetails.amount,
|
||||
toAddress: payProDetails.toAddress,
|
||||
description: payProDetails.memo,
|
||||
paypro: payProDetails
|
||||
paypro: payProDetails,
|
||||
coin: coin,
|
||||
};
|
||||
scannerService.pausePreview();
|
||||
$state.go('tabs.send', {}, {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<ion-content class="add-bottom-for-cta">
|
||||
<div class="list">
|
||||
<div class="item head">
|
||||
<div class="item head" ng-hide="criticalError">
|
||||
<div class="sending-label">
|
||||
<img src="img/icon-tx-sent-outline.svg">
|
||||
<span translate ng-if="!tx.sendMax">Sending</span>
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
<span class="item-note" ng-if="paymentExpired" ng-style="{'color': 'red'}" translate>Expired</span>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<div class="item" ng-hide="criticalError">
|
||||
<span class="label" translate>To</span>
|
||||
<span class="payment-proposal-to" ng-if="!recipientType">
|
||||
<img src="img/icon-bitcoin-small.svg">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue