handle error / incomplete on receive
This commit is contained in:
parent
e00fb50674
commit
6dba17937f
5 changed files with 102 additions and 55 deletions
|
|
@ -1,6 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $ionicPopover, $timeout, platformInfo, nodeWebkit, addressService, profileService, configService, lodash) {
|
||||
angular.module('copayApp.controllers').controller('tabReceiveController', function($scope, $ionicPopover, $timeout, platformInfo, nodeWebkit, walletService, profileService, configService, lodash, gettextCatalog) {
|
||||
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
|
||||
$scope.init = function() {
|
||||
$scope.index = 0;
|
||||
|
|
@ -26,7 +28,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
|
||||
$scope.$on("$ionicSlides.slideChangeEnd", function(event, data) {
|
||||
$scope.index = data.slider.activeIndex;
|
||||
$scope.setAddress(false);
|
||||
$scope.setAddress();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -70,10 +72,24 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
};
|
||||
|
||||
$scope.setAddress = function(forceNew) {
|
||||
if ($scope.generatingAddress) return;
|
||||
|
||||
$scope.addr = null;
|
||||
$scope.addrError = null;
|
||||
|
||||
var wallet = $scope.wallets[$scope.index];
|
||||
if (!wallet.isComplete()) {
|
||||
$scope.incomplete = true;
|
||||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.incomplete = false;
|
||||
$scope.generatingAddress = true;
|
||||
$timeout(function() {
|
||||
addressService.getAddress($scope.wallets[$scope.index].id, forceNew, function(err, addr) {
|
||||
walletService.getAddress($scope.wallets[$scope.index], forceNew, function(err, addr) {
|
||||
$scope.generatingAddress = false;
|
||||
if (err) {
|
||||
$scope.addrError = err;
|
||||
|
|
@ -88,25 +104,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
|
||||
|
||||
$scope.setWallets = function() {
|
||||
if (!profileService.profile) return;
|
||||
|
||||
var config = configService.getSync();
|
||||
config.colorFor = config.colorFor || {};
|
||||
config.aliasFor = config.aliasFor || {};
|
||||
|
||||
// Sanitize empty wallets (fixed in BWC 1.8.1, and auto fixed when wallets completes)
|
||||
var credentials = lodash.filter(profileService.profile.credentials, 'walletName');
|
||||
var ret = lodash.map(credentials, function(c) {
|
||||
return {
|
||||
m: c.m,
|
||||
n: c.n,
|
||||
name: config.aliasFor[c.walletId] || c.walletName,
|
||||
id: c.walletId,
|
||||
color: config.colorFor[c.walletId] || '#4A90E2',
|
||||
};
|
||||
});
|
||||
|
||||
$scope.wallets = lodash.sortBy(ret, 'name');
|
||||
$scope.wallets = profileService.getWallets();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue