update tx proposals on #send

This commit is contained in:
Matias Alejo Garcia 2014-11-30 18:35:30 -03:00
parent c215b3c15e
commit 3ea948e6ba
2 changed files with 15 additions and 17 deletions

View File

@ -41,7 +41,9 @@ angular.module('copayApp.controllers').controller('SendController',
});
};
$scope.updateTxs = function() {
$scope.updateTxs = _.throttle(function() {
console.log('[send.js.44:updateTxs:]'); //TODO
var w = $rootScope.wallet;
if (!w) return;
@ -60,11 +62,12 @@ angular.module('copayApp.controllers').controller('SendController',
}
});
$scope.txps = res.txs;
};
}, 1000);
/**
* Setting the two related amounts as properties prevents an infinite
* recursion for watches while preserving the original angular updates
*
*/
Object.defineProperty($scope,
"alternative", {
@ -106,11 +109,14 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.init = function() {
$rootScope.pendingTxCount = 0;
$scope.updateTxs();
setTimeout(function() {
$scope.loading = false;
$rootScope.$digest();
}, 1);
}
var w = $rootScope.wallet;
w.on('txProposalEvent', $scope.updateTxs);
};
$scope.$on("$destroy", function(){
var w = $rootScope.wallet;
w.removeListener('txProposalEvent', $scope.updateTxs );
});
$scope.showAddressBook = function() {
return w && _.keys(w.addressBook).length > 0;
@ -419,16 +425,14 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.sign = function(ntxid) {
$scope.loading = true;
$scope.error = $scope.success = null;
w.signAndSend(ntxid, function(err, id, status) {
$scope.loading = false;
$scope.notifyStatus(status);
$scope.updateTxs();
});
};
$scope.reject = function(ntxid) {
$scope.loading = true;
$rootScope.txAlertCount = 0;
w.reject(ntxid);
notification.warning('Transaction rejected', 'You rejected the transaction successfully');
$scope.updateTxs();

View File

@ -126,7 +126,6 @@ angular.module('copayApp.services')
root.installWalletHandlers = function(w) {
var wid = w.getId();
w.on('connectionError', function() {
console.log('err', w.getName()); //TODO
if (root.isFocused(wid)) {
var message = "Could not connect to the Insight server. Check your settings and network configuration";
notification.error('Networking Error', message);
@ -134,7 +133,6 @@ angular.module('copayApp.services')
});
w.on('corrupt', function(peerId) {
console.log('corr', w.getName()); //TODO
if (root.isFocused(wid)) {
notification.error('Error', $filter('translate')('Received corrupt message from ') + peerId);
}
@ -149,7 +147,6 @@ angular.module('copayApp.services')
});
w.on('tx', function(address, isChange) {
console.log('tx', w.getName()); //TODO
if (!isChange) {
notification.funds('Funds received on ' + w.getName(), address);
}
@ -159,14 +156,12 @@ angular.module('copayApp.services')
});
w.on('balanceUpdated', function() {
console.log('b', w.getName()); //TODO
balanceService.update(w, function() {
$rootScope.$digest();
}, root.isFocused(wid));
});
w.on('insightReconnected', function() {
console.log('i', w.getName()); //TODO
$rootScope.reconnecting = false;
balanceService.update(w, function() {
$rootScope.$digest();
@ -174,14 +169,13 @@ angular.module('copayApp.services')
});
w.on('insightError', function() {
console.log('i', w.getName()); //TODO
if (root.isFocused(wid)) {
$rootScope.reconnecting = true;
$rootScope.$digest();
}
});
w.on('newAddresses', function() {
console.log('newAddress', w.getName()); //TODO
// Nothing yet
});
w.on('txProposalsUpdated', function() {