Merge pull request #5464 from matiu/bug/bws-error-handing
Bug/bws error handing
This commit is contained in:
commit
b61157bda3
18 changed files with 78 additions and 57 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, platformInfo) {
|
||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, bwcError, platformInfo) {
|
||||
var UNUSED_ADDRESS_LIMIT = 5;
|
||||
var BALANCE_ADDRESS_LIMIT = 5;
|
||||
var config;
|
||||
|
|
@ -20,7 +20,7 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
walletService.getMainAddresses($scope.wallet, {}, function(err, addresses) {
|
||||
if (err) {
|
||||
ongoingProcess.set('gettingAddresses', false);
|
||||
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||
}
|
||||
|
||||
var allAddresses = addresses;
|
||||
|
|
@ -28,7 +28,7 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
|||
walletService.getBalance($scope.wallet, {}, function(err, resp) {
|
||||
ongoingProcess.set('gettingAddresses', false);
|
||||
if (err) {
|
||||
return popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||
}
|
||||
|
||||
withBalance = resp.byAddress;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('copayersController',
|
||||
function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, appConfigService, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
|
||||
function($scope, $log, $timeout, $stateParams, $state, $rootScope, $ionicHistory, appConfigService, lodash, profileService, walletService, popupService, bwcError, platformInfo, gettextCatalog, ongoingProcess) {
|
||||
|
||||
var appName = appConfigService.userVisibleName;
|
||||
var appUrl = appConfigService.url;
|
||||
|
|
@ -20,8 +20,7 @@ angular.module('copayApp.controllers').controller('copayersController',
|
|||
$log.debug('Updating wallet:' + $scope.wallet.name)
|
||||
walletService.getStatus($scope.wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
$log.error(err); //TODO
|
||||
return;
|
||||
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||
}
|
||||
$scope.wallet.status = status;
|
||||
$scope.copayers = $scope.wallet.status.wallet.copayers;
|
||||
|
|
|
|||
|
|
@ -191,9 +191,7 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
return;
|
||||
}
|
||||
|
||||
walletService.updateRemotePreferences(client, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
walletService.updateRemotePreferences(client);
|
||||
|
||||
if ($scope.seedSource.id == 'set') {
|
||||
profileService.setBackupFlag(client.credentials.walletId);
|
||||
|
|
|
|||
|
|
@ -340,9 +340,7 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
};
|
||||
|
||||
var finish = function(wallet) {
|
||||
walletService.updateRemotePreferences(wallet, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + wallet.credentials.walletId)
|
||||
});
|
||||
walletService.updateRemotePreferences(wallet);
|
||||
|
||||
profileService.setBackupFlag(wallet.credentials.walletId);
|
||||
if ($stateParams.fromOnboarding) {
|
||||
|
|
|
|||
|
|
@ -169,9 +169,7 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
return;
|
||||
}
|
||||
|
||||
walletService.updateRemotePreferences(client, {}, function() {
|
||||
$log.debug('Remote preferences saved for:' + client.credentials.walletId)
|
||||
});
|
||||
walletService.updateRemotePreferences(client);
|
||||
$ionicHistory.removeBackView();
|
||||
|
||||
if (!client.isComplete()) {
|
||||
|
|
|
|||
|
|
@ -66,9 +66,7 @@ angular.module('copayApp.controllers').controller('preferencesAltCurrencyControl
|
|||
|
||||
$ionicHistory.goBack();
|
||||
saveLastUsed(newAltCurrency);
|
||||
walletService.updateRemotePreferences(profileService.getWallets(), {}, function() {
|
||||
$log.debug('Remote preferences saved');
|
||||
});
|
||||
walletService.updateRemotePreferences(profileService.getWallets());
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@ angular.module('copayApp.controllers').controller('preferencesFeeController', fu
|
|||
feeService.getFeeLevels(function(err, levels) {
|
||||
$scope.loadingFee = false;
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
//Error is already formatted
|
||||
popupService.showAlert(err);
|
||||
return;
|
||||
}
|
||||
$scope.feeLevels = levels;
|
||||
|
|
|
|||
|
|
@ -27,9 +27,7 @@ angular.module('copayApp.controllers').controller('preferencesLanguageController
|
|||
uxLanguage._set(newLang);
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.warn(err);
|
||||
walletService.updateRemotePreferences(profileService.getWallets(), {}, function() {
|
||||
$log.debug('Remote preferences saved');
|
||||
});
|
||||
walletService.updateRemotePreferences(profileService.getWallets());
|
||||
});
|
||||
|
||||
$ionicHistory.goBack();
|
||||
|
|
|
|||
|
|
@ -33,9 +33,7 @@ angular.module('copayApp.controllers').controller('preferencesUnitController', f
|
|||
if (err) $log.warn(err);
|
||||
|
||||
$ionicHistory.goBack();
|
||||
walletService.updateRemotePreferences(profileService.getWallets(), {}, function() {
|
||||
$log.debug('Remote preferences saved');
|
||||
});
|
||||
walletService.updateRemotePreferences(profileService.getWallets())
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabHomeController',
|
||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, bitpayCardService, startupService, addressbookService, feedbackService) {
|
||||
function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, $window, gettextCatalog, lodash, popupService, ongoingProcess, externalLinkService, latestReleaseService, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, appConfigService, bitpayCardService, startupService, addressbookService, feedbackService, bwcError) {
|
||||
var wallet;
|
||||
var listeners = [];
|
||||
var notifications = [];
|
||||
|
|
@ -208,8 +208,9 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
|||
lodash.each($scope.wallets, function(wallet) {
|
||||
walletService.getStatus(wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
if (err === 'WALLET_NOT_REGISTERED') wallet.error = gettextCatalog.getString('Wallet not registered');
|
||||
else wallet.error = gettextCatalog.getString('Could not update');;
|
||||
|
||||
wallet.error = (err === 'WALLET_NOT_REGISTERED') ? gettextCatalog.getString('Wallet not registered') : bwcError.msg(err);
|
||||
|
||||
$log.error(err);
|
||||
} else {
|
||||
wallet.error = null;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,12 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
$scope.generatingAddress = true;
|
||||
walletService.getAddress($scope.wallet, forceNew, function(err, addr) {
|
||||
$scope.generatingAddress = false;
|
||||
if (err) popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
|
||||
if (err) {
|
||||
//Error is already formated
|
||||
return popupService.showAlert(err);
|
||||
}
|
||||
|
||||
$scope.addr = addr;
|
||||
if ($scope.walletAddrs[$scope.wallet.id]) $scope.walletAddrs[$scope.wallet.id] = addr;
|
||||
$timeout(function() {
|
||||
|
|
@ -129,7 +134,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
$scope.updateCurrentWallet = function() {
|
||||
walletService.getStatus($scope.wallet, {}, function(err, status) {
|
||||
if (err) {
|
||||
$log.error(err);
|
||||
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||
}
|
||||
$timeout(function() {
|
||||
$scope.wallet = profileService.getWallet($scope.wallet.id);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $rootScope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo) {
|
||||
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $rootScope, $log, $timeout, $ionicScrollDelegate, addressbookService, profileService, lodash, $state, walletService, incomingData, popupService, platformInfo, bwcError, gettextCatalog) {
|
||||
|
||||
var originalList;
|
||||
var CONTACTS_SHOW_LIMIT;
|
||||
|
|
@ -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) {
|
||||
|
|
@ -132,9 +136,14 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
|
|||
var index = 0;
|
||||
lodash.each(wallets, function(w) {
|
||||
walletService.getStatus(w, {}, function(err, status) {
|
||||
|
||||
++index;
|
||||
if (err && !status) {
|
||||
$log.error(err);
|
||||
// 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;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
|||
if (err === 'WALLET_NOT_REGISTERED') {
|
||||
$scope.walletNotRegistered = true;
|
||||
} else {
|
||||
$scope.updateStatusError = bwcError.msg(err, gettextCatalog.getString('BWS Error'));
|
||||
$scope.updateStatusError = bwcError.msg(err, gettextCatalog.getString('Could not update wallet'));
|
||||
}
|
||||
$scope.status = null;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -11,12 +11,8 @@ angular.module('copayApp.services').factory('emailService', function($log, confi
|
|||
return w.credentials.walletId;
|
||||
});
|
||||
|
||||
lodash.each(wallets, function(w) {
|
||||
walletService.updateRemotePreferences(w, {
|
||||
email: opts.enabled ? opts.email : null
|
||||
}, function(err) {
|
||||
if (err) $log.warn(err);
|
||||
});
|
||||
walletService.updateRemotePreferences(wallets, {
|
||||
email: opts.enabled ? opts.email : null
|
||||
});
|
||||
|
||||
var config = configService.getSync();
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
function getNewTxs(newTxs, skip, cb) {
|
||||
getTxsFromServer(wallet, skip, endingTxid, requestLimit, function(err, res, shouldContinue) {
|
||||
if (err) {
|
||||
$log.warn(bwcError.msg(err, 'BWS Error')); //TODO
|
||||
$log.warn(bwcError.msg(err, 'Server Error')); //TODO
|
||||
if (err instanceof errors.CONNECTION_ERROR || (err.message && err.message.match(/5../))) {
|
||||
$log.info('Retrying history download in 5 secs...');
|
||||
return $timeout(function() {
|
||||
|
|
@ -654,20 +654,24 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
|
||||
root.updateRemotePreferences = function(clients, prefs, cb) {
|
||||
prefs = prefs || {};
|
||||
cb = cb || function() {};
|
||||
|
||||
if (!lodash.isArray(clients))
|
||||
clients = [clients];
|
||||
|
||||
function updateRemotePreferencesFor(clients, prefs, cb) {
|
||||
function updateRemotePreferencesFor(clients, prefs, next) {
|
||||
var wallet = clients.shift();
|
||||
if (!wallet) return cb();
|
||||
if (!wallet) return next();
|
||||
$log.debug('Saving remote preferences', wallet.credentials.walletName, prefs);
|
||||
|
||||
wallet.savePreferences(prefs, function(err) {
|
||||
// we ignore errors here
|
||||
if (err) $log.warn(err);
|
||||
|
||||
updateRemotePreferencesFor(clients, prefs, cb);
|
||||
if (err) {
|
||||
popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not save preferences on the server')));
|
||||
return next(err);
|
||||
}
|
||||
|
||||
updateRemotePreferencesFor(clients, prefs, next);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -678,9 +682,13 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
prefs.language = uxLanguage.getCurrentLanguage();
|
||||
prefs.unit = config.unitCode;
|
||||
|
||||
updateRemotePreferencesFor(clients, prefs, function(err) {
|
||||
updateRemotePreferencesFor(lodash.clone(clients), prefs, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
$log.debug('Remote preferences saved for' + lodash.map(clients, function(x) {
|
||||
return x.credentials.walletId;
|
||||
}).join(','));
|
||||
|
||||
lodash.each(clients, function(c) {
|
||||
c.preferences = lodash.assign(prefs, c.preferences);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@
|
|||
</div>
|
||||
<div class="wallet-balance__description" translate>The amount of bitcoin stored in this wallet with less than 1 blockchain confirmation.</div>
|
||||
</div>
|
||||
<div class="wallet-balance__list list card">
|
||||
<div class="wallet-balance__list list card" ng-show="status.lockedBalanceSat!=0">
|
||||
<div class="wallet-balance__item item">
|
||||
<img class="wallet-balance__icon" src="img/icon-lock.svg" width="18"\>
|
||||
<div class="wallet-balance__content no-border">
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<div class="col col-90 center-block bit-address text-center">
|
||||
<div class="item item-icon-left">
|
||||
<i class="icon icon-svg receive-tab-bitcoin-icon"><img src="img/icon-bitcoin-symbol.svg"></i>
|
||||
<span class="bit-address-gen-address" ng-if="!generatingAddress" translate>address not yet available</span>
|
||||
<span class="bit-address-gen-address" translate>address not yet available</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -54,9 +54,6 @@
|
|||
<div class="row qr">
|
||||
<div class="text-center col center-block" copy-to-clipboard="addr" ng-repeat="wallet in wallets track by $index" ng-class="walletPosition($index)">
|
||||
<qrcode ng-if="walletAddrs[wallet.id]" size="220" data="bitcoin:{{walletAddrs[wallet.id]}}" color="#334"></qrcode>
|
||||
<div ng-if="!walletAddrs[wallet.id]" style="height:225px; width:220px; margin:auto;padding-top: 25%;position:absolute;left:50%;top:50%;z-index:1;">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="qr-options" class="row text-center">
|
||||
|
|
@ -69,8 +66,8 @@
|
|||
<div class="center-block bit-address text-center" ng-repeat="wallet in wallets track by $index" ng-class="walletPosition($index)">
|
||||
<div class="item item-icon-left item-icon-right">
|
||||
<i class="icon icon-svg receive-tab-bitcoin-icon"><img src="img/icon-bitcoin-symbol.svg"></i>
|
||||
<span class="bit-address-gen-address" ng-if="generatingAddress">...</span>
|
||||
<span class="bit-address-gen-address" ng-if="!generatingAddress" class="ellipsis">{{walletAddrs[wallet.id]}}</span>
|
||||
<span class="bit-address-gen-address" ng-show="!generatingAddress" class="ellipsis">{{walletAddrs[wallet.id]}}</span>
|
||||
<span class="bit-address-gen-address" ng-show="!generatingAddress && !walletAddrs[wallet.id]" translate>address not available</span>
|
||||
<i class="icon ion-ios-arrow-right"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue