balance Service
This commit is contained in:
parent
a8f0401e8e
commit
57299d675e
31 changed files with 585 additions and 645 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('SidebarController', function($scope, $rootScope, $location, controllerUtils) {
|
||||
angular.module('copayApp.controllers').controller('SidebarController', function($scope, $rootScope, $location, $timeout, identityService) {
|
||||
|
||||
$scope.menu = [{
|
||||
'title': 'Home',
|
||||
|
|
@ -24,21 +24,6 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
|
|||
'link': 'more'
|
||||
}];
|
||||
|
||||
$scope.refresh = function() {
|
||||
var w = $rootScope.wallet;
|
||||
if (!w) return;
|
||||
|
||||
if (w.isReady()) {
|
||||
w.sendWalletReady();
|
||||
if ($rootScope.addrInfos.length > 0) {
|
||||
controllerUtils.clearBalanceCache(w);
|
||||
controllerUtils.updateBalance(w, function() {
|
||||
$rootScope.$digest();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.signout = function() {
|
||||
$scope.$emit('signout');
|
||||
};
|
||||
|
|
@ -47,35 +32,32 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
|
|||
return item.link && item.link == $location.path().split('/')[1];
|
||||
};
|
||||
|
||||
if ($rootScope.wallet) {
|
||||
$rootScope.$watch('wallet.id', function() {
|
||||
$scope.walletSelection = false;
|
||||
$scope.getWallets();
|
||||
});
|
||||
}
|
||||
|
||||
$scope.switchWallet = function(wid) {
|
||||
controllerUtils.setFocusedWallet(wid);
|
||||
identityService.setFocusedWallet(wid);
|
||||
};
|
||||
|
||||
$scope.toggleWalletSelection = function() {
|
||||
$scope.walletSelection = !$scope.walletSelection;
|
||||
if (!$scope.walletSelection) return;
|
||||
|
||||
$scope.getWallets();
|
||||
$scope.setWallets();
|
||||
};
|
||||
|
||||
$scope.getWallets = function() {
|
||||
|
||||
$scope.init = function() {
|
||||
if ($rootScope.wallet) {
|
||||
$rootScope.$watch('wallet', function() {
|
||||
$scope.walletSelection = false;
|
||||
$scope.setWallets();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$scope.setWallets = function() {
|
||||
if (!$rootScope.iden) return;
|
||||
$scope.wallets = [];
|
||||
var wids = _.pluck($rootScope.iden.listWallets(), 'id');
|
||||
_.each(wids, function(wid) {
|
||||
if (controllerUtils.isFocusedWallet(wid)) return;
|
||||
var w = $rootScope.iden.getWalletById(wid);
|
||||
$scope.wallets.push(w);
|
||||
controllerUtils.updateBalance(w, function() {
|
||||
$rootScope.$digest();
|
||||
})
|
||||
var ret = _.filter($rootScope.iden.listWallets(), function(w) {
|
||||
return !identityService.isFocused(w.getId());
|
||||
});
|
||||
$scope.wallets = ret;
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue