mirror of https://github.com/BTCPrivate/copay.git
better send tab without internet
This commit is contained in:
parent
f063c06751
commit
aa05165710
|
@ -79,12 +79,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
var filteredWallets = [];
|
||||
var index = 0;
|
||||
var enoughFunds = false;
|
||||
var walletsUpdated = 0;
|
||||
|
||||
lodash.each($scope.wallets, function(w) {
|
||||
walletService.getStatus(w, {}, function(err, status) {
|
||||
if (err || !status) {
|
||||
$log.error(err);
|
||||
} else {
|
||||
walletsUpdated++;
|
||||
w.status = status;
|
||||
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name);
|
||||
if (status.availableBalanceSat > toAmount) {
|
||||
|
@ -94,6 +96,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
}
|
||||
|
||||
if (++index == $scope.wallets.length) {
|
||||
|
||||
if (!lodash.isEmpty(filteredWallets)) {
|
||||
$scope.wallets = lodash.clone(filteredWallets);
|
||||
if ($scope.useSendMax) {
|
||||
|
@ -105,9 +108,23 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
|||
}
|
||||
} else initConfirm();
|
||||
} else {
|
||||
if (!enoughFunds) $scope.insufficientFunds = true;
|
||||
displayValues();
|
||||
$log.warn('No wallet available to make the payment');
|
||||
|
||||
// Were we able to update any wallet?
|
||||
if (walletsUpdated) {
|
||||
if (!enoughFunds) $scope.insufficientFunds = true;
|
||||
displayValues();
|
||||
$log.warn('No wallet available to make the payment');
|
||||
} else {
|
||||
popupService.showAlert(gettextCatalog.getString('Could not update wallets'), bwcError.msg(err), function() {
|
||||
$ionicHistory.nextViewOptions({
|
||||
disableAnimate: true,
|
||||
historyRoot: true
|
||||
});
|
||||
$ionicHistory.clearHistory();
|
||||
$state.go('tabs.send');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
|
|
|
@ -94,8 +94,8 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
$timeout(function() {
|
||||
item.getAddress(function(err, addr) {
|
||||
if (err || !addr) {
|
||||
$log.error(err);
|
||||
return;
|
||||
//Error is already formated
|
||||
return popupService.showAlert(err);
|
||||
}
|
||||
$log.debug('Got toAddress:' + addr + ' | ' + item.name);
|
||||
return $state.transitionTo('tabs.send.amount', {
|
||||
|
@ -109,6 +109,10 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
// THIS is ONLY to show the 'buy bitcoins' message
|
||||
// does not has any other function.
|
||||
|
||||
var updateHasFunds = function() {
|
||||
|
||||
if ($rootScope.everHasFunds) {
|
||||
|
@ -128,20 +132,18 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
});
|
||||
}
|
||||
|
||||
$scope.checkingBalanceError = false;
|
||||
$scope.checkingBalance = true;
|
||||
var index = 0,
|
||||
errorShown = 0;
|
||||
var index = 0;
|
||||
lodash.each(wallets, function(w) {
|
||||
walletService.getStatus(w, {}, function(err, status) {
|
||||
|
||||
++index;
|
||||
if (err && !status) {
|
||||
$log.error(err);
|
||||
if (!errorShown++) popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||
$scope.checkingBalanceError = true;
|
||||
return;
|
||||
|
||||
// error updating the wallet. Probably a network error, do not show
|
||||
// the 'buy bitcoins' message.
|
||||
|
||||
$scope.hasFunds = true;
|
||||
} else if (status.availableBalanceSat > 0) {
|
||||
$scope.hasFunds = true;
|
||||
$rootScope.everHasFunds = true;
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-title>{{'Send' | translate}}</ion-nav-title>
|
||||
</ion-nav-bar>
|
||||
<ion-content ng-show="checkingBalanceError">
|
||||
<div class="list card">
|
||||
<div class="item item-icon-left">
|
||||
<i class="ion-alert-circled icon"></i>
|
||||
<span translate>Could not update wallets</span>
|
||||
</div>
|
||||
</div>
|
||||
</ion-content >
|
||||
<ion-content ng-show="!checkingBalance">
|
||||
<div ng-if="hasFunds == false" class="zero-state">
|
||||
<div>
|
||||
|
|
Loading…
Reference in New Issue