refresh status when bwsEvent arrives

This commit is contained in:
Gabriel Bazán 2016-09-22 12:02:45 -03:00
parent 868e6b086f
commit e3257ec5c0
1 changed files with 20 additions and 1 deletions

View File

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('copayersController',
function($scope, $log, $ionicNavBarDelegate, $stateParams, $state, profileService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
function($scope, $log, $ionicNavBarDelegate, $timeout, $stateParams, $state, $rootScope, lodash, profileService, walletService, popupService, platformInfo, gettextCatalog, ongoingProcess) {
if (!$stateParams.walletId) {
$log.debug('No wallet provided...back to home');
return $state.go('tabs.home');
@ -53,4 +53,23 @@ angular.module('copayApp.controllers').controller('copayersController',
window.plugins.socialsharing.share(message, gettextCatalog.getString('Invitation to share a Copay Wallet'), null, null);
}
};
$rootScope.$on('bwsEvent', function() {
updateWallet();
});
var updateWallet = function() {
$log.debug('Updating wallet:' + wallet.name)
walletService.getStatus(wallet, {}, function(err, status) {
if (err) {
$log.error(err); //TODO
return;
}
wallet.status = status;
$scope.copayers = wallet.status.wallet.copayers;
$timeout(function() {
$scope.$apply();
});
});
};
});