Improves updating addressbook

This commit is contained in:
Gustavo Maximiliano Cortez 2015-11-02 12:04:18 -03:00
commit 18e5d9f615
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
2 changed files with 11 additions and 6 deletions

View file

@ -1011,7 +1011,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}; };
self.setAddressbook = function() { self.setAddressbook = function(ab) {
if (ab) {
self.addressbook = ab;
return;
}
addressbookService.list(function(err, ab) { addressbookService.list(function(err, ab) {
if (err) { if (err) {
$log.error('Error getting the addressbook'); $log.error('Error getting the addressbook');
@ -1027,8 +1032,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.updateHistory(); self.updateHistory();
}); });
$rootScope.$on('Local/AddressbookUpdated', function(event) { $rootScope.$on('Local/AddressbookUpdated', function(event, ab) {
self.setAddressbook(); self.setAddressbook(ab);
}); });
// UX event handlers // UX event handlers

View file

@ -214,7 +214,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.error = err; $scope.error = err;
return; return;
} }
$rootScope.$emit('Local/AddressbookUpdated'); $rootScope.$emit('Local/AddressbookUpdated', ab);
$scope.list = ab; $scope.list = ab;
$scope.editAddressbook = true; $scope.editAddressbook = true;
$scope.toggleEditAddressbook(); $scope.toggleEditAddressbook();
@ -231,7 +231,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.error = err; $scope.error = err;
return; return;
} }
$rootScope.$emit('Local/AddressbookUpdated'); $rootScope.$emit('Local/AddressbookUpdated', ab);
$scope.list = ab; $scope.list = ab;
$scope.$digest(); $scope.$digest();
}); });