Fix next address
This commit is contained in:
parent
fe8dcd2f94
commit
7e9d47c8e9
2 changed files with 23 additions and 14 deletions
|
|
@ -31,7 +31,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
|
||||
$scope.loadAddresses = function(wallet, index) {
|
||||
walletService.getAddress(wallet, false, function(err, addr) {
|
||||
$scope.walletAddrs[wallet.id] = addr || null;
|
||||
$scope.walletAddrs[wallet.id] = addr;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -95,13 +95,6 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
|
||||
|
||||
$scope.$on('Wallet/Changed', function(event, wallet) {
|
||||
$scope.wallet = wallet;
|
||||
$scope.walletIndex = lodash.findIndex($scope.wallets, function(wallet) {
|
||||
return wallet.id == $scope.wallet.id;
|
||||
});
|
||||
if (!$scope.walletAddrs[wallet.id]) $scope.setAddress(false);
|
||||
else $scope.addr = $scope.walletAddrs[wallet.id];
|
||||
$scope.$apply();
|
||||
if (!wallet) {
|
||||
$log.debug('No wallet provided');
|
||||
return;
|
||||
|
|
@ -112,6 +105,18 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
}
|
||||
$scope.wallet = wallet;
|
||||
$log.debug('Wallet changed: ' + wallet.name);
|
||||
|
||||
$scope.walletIndex = lodash.findIndex($scope.wallets, function(wallet) {
|
||||
return wallet.id == $scope.wallet.id;
|
||||
});
|
||||
|
||||
if (!$scope.walletAddrs[wallet.id]) $scope.setAddress(false);
|
||||
else $scope.addr = $scope.walletAddrs[wallet.id];
|
||||
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
|
||||
});
|
||||
|
||||
$scope.updateCurrentWallet = function() {
|
||||
|
|
@ -135,6 +140,7 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
|
|||
$scope.loadAddresses(wallet);
|
||||
});
|
||||
|
||||
|
||||
listeners = [
|
||||
$rootScope.$on('bwsEvent', function(e, walletId, type, n) {
|
||||
// Update current address
|
||||
|
|
|
|||
|
|
@ -800,17 +800,20 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
};
|
||||
|
||||
root.getAddress = function(wallet, forceNew, cb) {
|
||||
|
||||
storageService.getLastAddress(wallet.id, function(err, addr) {
|
||||
if (err) return cb(err);
|
||||
|
||||
if (!forceNew && addr) return cb(null, addr);
|
||||
|
||||
createAddress(wallet, function(err, _addr) {
|
||||
if (err) return cb(err, addr);
|
||||
storageService.storeLastAddress(wallet.id, _addr, function() {
|
||||
if (err) return cb(err);
|
||||
return cb(null, _addr);
|
||||
root.isReady(wallet, function(err) {
|
||||
if (err) return cb(err);
|
||||
|
||||
createAddress(wallet, function(err, _addr) {
|
||||
if (err) return cb(err, addr);
|
||||
storageService.storeLastAddress(wallet.id, _addr, function() {
|
||||
if (err) return cb(err);
|
||||
return cb(null, _addr);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue