Hide empty addresses from othe copayers
This commit is contained in:
parent
04b6aa4003
commit
fd2cf54eb4
5 changed files with 24 additions and 9 deletions
|
|
@ -389,7 +389,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="large-9 medium-12 columns" ng-if="addresses[0]">
|
<div class="large-9 medium-12 columns" ng-if="addresses[0]">
|
||||||
<div class="large-8 medium-8 columns" ng-init="showAll=0">
|
<div class="large-8 medium-8 columns" ng-init="showAll=0">
|
||||||
<a class="panel radius db" ng-repeat="addr in addresses | limitAddress:showAll"
|
<a class="panel radius db" ng-repeat="addr in addresses|removeEmpty|limitAddress:showAll"
|
||||||
ng-click="selectAddress(addr)"
|
ng-click="selectAddress(addr)"
|
||||||
ng-class="{selected : addr.address == selectedAddr.address}">
|
ng-class="{selected : addr.address == selectedAddr.address}">
|
||||||
|
|
||||||
|
|
@ -411,7 +411,7 @@
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="secondary radius" ng-click="showAll=!showAll" ng-show="addresses.length != (addresses|limitAddress).length">
|
<a class="secondary radius" ng-click="showAll=!showAll" ng-show="(addresses|removeEmpty).length != (addresses|removeEmpty|limitAddress).length">
|
||||||
<span ng-if="!showAll">Show all</span>
|
<span ng-if="!showAll">Show all</span>
|
||||||
<span ng-if="showAll">Show less</span>
|
<span ng-if="showAll">Show less</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ angular.module('copayApp.controllers').controller('AddressesController',
|
||||||
$scope.addresses.push({
|
$scope.addresses.push({
|
||||||
'address': addrinfo.addressStr,
|
'address': addrinfo.addressStr,
|
||||||
'balance': $rootScope.balanceByAddr ? $rootScope.balanceByAddr[addrinfo.addressStr] : 0,
|
'balance': $rootScope.balanceByAddr ? $rootScope.balanceByAddr[addrinfo.addressStr] : 0,
|
||||||
'isChange': addrinfo.isChange
|
'isChange': addrinfo.isChange,
|
||||||
|
'owned': addrinfo.owned
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$scope.selectedAddr = $scope.addresses[0];
|
$scope.selectedAddr = $scope.addresses[0];
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,14 @@ angular.module('copayApp.filters', [])
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
.filter('removeEmpty', function() {
|
||||||
|
return function(elements) {
|
||||||
|
// Hide empty addresses from other copayers
|
||||||
|
return elements.filter(function(e) {
|
||||||
|
return e.owned || e.balance > 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
.filter('limitAddress', function() {
|
.filter('limitAddress', function() {
|
||||||
return function(elements, showAll) {
|
return function(elements, showAll) {
|
||||||
if (elements.length <= 1 || showAll) {
|
if (elements.length <= 1 || showAll) {
|
||||||
|
|
|
||||||
|
|
@ -246,18 +246,22 @@ PublicKeyRing.prototype.getCosigner = function(pubKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PublicKeyRing.prototype.getAddressesInfo = function(opts) {
|
PublicKeyRing.prototype.getAddressesInfo = function(opts, pubkey) {
|
||||||
var ret = [];
|
var ret = [];
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var cosigner = pubkey && this.getCosigner(pubkey);
|
||||||
this.indexes.forEach(function(index) {
|
this.indexes.forEach(function(index) {
|
||||||
ret = ret.concat(self.getAddressesInfoForIndex(index, opts));
|
ret = ret.concat(self.getAddressesInfoForIndex(index, opts, cosigner));
|
||||||
});
|
});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
PublicKeyRing.prototype.getAddressesInfoForIndex = function(index, opts) {
|
PublicKeyRing.prototype.getAddressesInfoForIndex = function(index, opts, cosigner) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
|
var isOwned = index.cosigner == Structure.SHARED_INDEX
|
||||||
|
|| index.cosigner == cosigner;
|
||||||
|
|
||||||
var ret = [];
|
var ret = [];
|
||||||
if (!opts.excludeChange) {
|
if (!opts.excludeChange) {
|
||||||
for (var i = 0; i < index.changeIndex; i++) {
|
for (var i = 0; i < index.changeIndex; i++) {
|
||||||
|
|
@ -265,7 +269,8 @@ PublicKeyRing.prototype.getAddressesInfoForIndex = function(index, opts) {
|
||||||
ret.unshift({
|
ret.unshift({
|
||||||
address: a,
|
address: a,
|
||||||
addressStr: a.toString(),
|
addressStr: a.toString(),
|
||||||
isChange: true
|
isChange: true,
|
||||||
|
owned: isOwned
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -276,7 +281,8 @@ PublicKeyRing.prototype.getAddressesInfoForIndex = function(index, opts) {
|
||||||
ret.unshift({
|
ret.unshift({
|
||||||
address: a,
|
address: a,
|
||||||
addressStr: a.toString(),
|
addressStr: a.toString(),
|
||||||
isChange: false
|
isChange: false,
|
||||||
|
owned: isOwned
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -588,7 +588,7 @@ Wallet.prototype.getAddressesStr = function(opts) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.getAddressesInfo = function(opts) {
|
Wallet.prototype.getAddressesInfo = function(opts) {
|
||||||
return this.publicKeyRing.getAddressesInfo(opts);
|
return this.publicKeyRing.getAddressesInfo(opts, this.publicKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.addressIsOwn = function(addrStr, opts) {
|
Wallet.prototype.addressIsOwn = function(addrStr, opts) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue