Alert for transaction support in navbar (red label).

Fixes Sign and Reject Transactions.

Known bugs:
	* After 5 continuous transactions, connection is lost with peers
	* 1-of-1 wallet does not refresh automatically
This commit is contained in:
Gustavo Cortez 2014-05-13 05:02:21 -03:00
parent cb00a5b629
commit 8a03225cd2
4 changed files with 18 additions and 9 deletions

View File

@ -55,8 +55,8 @@
<section class="top-bar-section {{isCollapsed && 'hide_menu' || 'show_menu'}}"> <section class="top-bar-section {{isCollapsed && 'hide_menu' || 'show_menu'}}">
<ul> <ul>
<li data-ng-repeat="item in menu" ui-route="/{{item.link}}" class="text-center" data-ng-class="{active: isActive(item)}"> <li data-ng-repeat="item in menu" ui-route="/{{item.link}}" class="text-center" data-ng-class="{active: isActive(item)}">
<a href="{{item.link}}"> <i class="{{item.icon}}"></i> {{item.title}} <a href="{{item.link}}"> <i class="{{item.icon}}"></i> {{item.title}}
<span ng-if="item.title=='Transactions'">({{$root.txslength}})</span> <span class="label alert round" ng-if="item.title=='Transactions' && $root.txslength > 0">{{$root.txslength}}</span>
</a> </a>
</li> </li>
</ul> </ul>

View File

@ -16,6 +16,7 @@ angular.module('copay.transactions').controller('TransactionsController',
: {type:'error', message: 'There was an error sending the Transaction'} : {type:'error', message: 'There was an error sending the Transaction'}
; ;
controllerUtils.updateTxs(); controllerUtils.updateTxs();
$scope.loading = false;
$rootScope.$digest(); $rootScope.$digest();
}); });
}; };
@ -28,15 +29,18 @@ angular.module('copay.transactions').controller('TransactionsController',
if (!ret) { if (!ret) {
$rootScope.flashMessage = {type:'error', message: 'There was an error signing the Transaction'}; $rootScope.flashMessage = {type:'error', message: 'There was an error signing the Transaction'};
controllerUtils.updateTxs(); controllerUtils.updateTxs();
$rootScope.$digest(); $scope.loading = false;
$rootScope.$digest();
return; return;
} }
var p = w.txProposals.getTxProposal(ntxid); var p = w.txProposals.getTxProposal(ntxid);
if (p.builder.isFullySigned()) { if (p.builder.isFullySigned()) {
$scope.send(ntxid); $scope.send(ntxid);
controllerUtils.updateTxs();
} }
else { else {
controllerUtils.updateTxs(); controllerUtils.updateTxs();
$scope.loading = false;
$rootScope.$digest(); $rootScope.$digest();
} }
}; };
@ -64,8 +68,7 @@ angular.module('copay.transactions').controller('TransactionsController',
var w = $rootScope.wallet; var w = $rootScope.wallet;
w.reject(ntxid); w.reject(ntxid);
$rootScope.flashMessage = {type:'warning', message: 'Transaction rejected by you'}; $rootScope.flashMessage = {type:'warning', message: 'Transaction rejected by you'};
controllerUtils.updateTxs(); $scope.loading = false;
// $rootScope.$digest();
}; };
}); });

View File

@ -346,7 +346,7 @@ Wallet.prototype.reject = function(ntxid) {
txp.rejectedBy[myId] = Date.now(); txp.rejectedBy[myId] = Date.now();
this.sendTxProposals(); this.sendTxProposals();
this.store(); this.store();
this.emit('refresh'); this.emit('txProposalsUpdated');
}; };
@ -367,7 +367,7 @@ Wallet.prototype.sign = function(ntxid) {
txp.signedBy[myId] = Date.now(); txp.signedBy[myId] = Date.now();
this.sendTxProposals(); this.sendTxProposals();
this.store(); this.store();
this.emit('refresh'); this.emit('txProposalsUpdated');
return true; return true;
} }
return false; return false;

View File

@ -85,6 +85,7 @@ angular.module('copay.controllerUtils')
w.on('txProposalsUpdated', function() { w.on('txProposalsUpdated', function() {
console.log('[ txProposalsUpdated ]'); //TODO console.log('[ txProposalsUpdated ]'); //TODO
root.updateTxs(); root.updateTxs();
root.updateBalance();
}); });
w.on('openError', root.onErrorDigest); w.on('openError', root.onErrorDigest);
w.on('connect', function(peerID) { w.on('connect', function(peerID) {
@ -153,8 +154,13 @@ angular.module('copay.controllerUtils')
txs.push(i); txs.push(i);
}); });
$rootScope.txs = txs; $rootScope.txs = txs;
console.log('[controllerUtils.js:155]',txs); //TODO var txps = 0;
$rootScope.txslength = txs.length; for(var i=0; i<txs.length;i++) {
if (!txs[i].finallyRejected && !txs[i].sentTs) {
txps++;
}
}
$rootScope.txslength = txps;
w.removeListener('txProposalsUpdated',root.updateTxs) w.removeListener('txProposalsUpdated',root.updateTxs)
w.once('txProposalsUpdated',root.updateTxs); w.once('txProposalsUpdated',root.updateTxs);
$rootScope.loading = false; $rootScope.loading = false;