fix pending

This commit is contained in:
Matias Alejo Garcia 2014-11-30 11:18:25 -03:00
parent b73f711fff
commit 01b678457d
2 changed files with 31 additions and 5 deletions

View File

@ -1383,6 +1383,35 @@ Wallet.prototype._getActionList = function(txp) {
return peers;
};
/**
* @desc Retrieve Pendings Transaction proposals (see {@link TxProposals})
* @return {Object[]} each object returned represents a transaction proposal
*/
Wallet.prototype.getPendingTxProposalsCount = function() {
var self = this;
var txps = this.txProposals.txps;
var maxRejectCount = this.maxRejectCount();
var myId = this.getMyCopayerId();
var pending =0, pendingForUs = 0;
_.each(txps, function(inTxp, ntxid) {
if (!inTxp.isPending(maxRejectCount))
return;
pending++;
if (!inTxp.signedBy[myId] && !inTxp.rejectedBy[myId] )
pendingForUs++
});
return {
pending: pending,
pendingForUs: pendingForUs,
};
};
/**
* @desc Retrieve Pendings Transaction proposals (see {@link TxProposals})
* @return {Object[]} each object returned represents a transaction proposal
@ -1391,7 +1420,6 @@ Wallet.prototype.getPendingTxProposals = function() {
var self = this;
var ret = [];
ret.txs = [];
var pendingForUs = 0;
var txps = this.txProposals.txps;
var maxRejectCount = this.maxRejectCount();
var satToUnit = 1 / this.settings.unitToSatoshi;
@ -1403,7 +1431,6 @@ Wallet.prototype.getPendingTxProposals = function() {
var txp = _.clone(inTxp);
txp.ntxid = ntxid;
pendingForUs++;
var addresses = {};
var outs = JSON.parse(txp.builder.vanilla.outs);
outs.forEach(function(o) {
@ -1426,7 +1453,6 @@ Wallet.prototype.getPendingTxProposals = function() {
ret.txs.push(txp);
});
ret.pendingForUs = pendingForUs;
return ret;
};

View File

@ -8,8 +8,8 @@ angular.module('copayApp.services')
var w = $rootScope.wallet;
if (!w) return;
var res = w.getPendingTxProposals();
$rootScope.pendingTxCount = res.pendingForUs;
var ret = w.getPendingTxProposalsCount();
$rootScope.pendingTxCount = ret.pendingForUs;
};
return root;
});