mirror of https://github.com/BTCPrivate/copay.git
commit
fbfc589c86
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, rateService) {
|
||||
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope, $timeout, $filter, rateService, notification) {
|
||||
$scope.init = function() {
|
||||
$rootScope.title = 'Home';
|
||||
|
||||
|
@ -8,10 +8,8 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
|||
$scope.isRateAvailable = false;
|
||||
|
||||
var w = $rootScope.wallet;
|
||||
w.on('txProposalEvent', function() { _updateTxs()});
|
||||
$timeout(function() {
|
||||
w.on('txProposalEvent', _updateTxs);
|
||||
_updateTxs();
|
||||
}, 1);
|
||||
|
||||
rateService.whenAvailable(function() {
|
||||
$scope.isRateAvailable = true;
|
||||
|
@ -20,19 +18,47 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
|||
};
|
||||
|
||||
// This is necesarry, since wallet can change in homeWallet, without running init() again.
|
||||
var removeWatch = $rootScope.$watch('wallet.id', function(newWallet, oldWallet) {
|
||||
var removeWatch;
|
||||
removeWatch = $rootScope.$watch('wallet.id', function(newWallet, oldWallet) {
|
||||
if ($rootScope.wallet && $rootScope.wallet.isComplete() && newWallet !== oldWallet) {
|
||||
|
||||
if (removeWatch)
|
||||
removeWatch();
|
||||
|
||||
if (oldWallet) {
|
||||
var oldw = $rootScope.iden.getWalletById(oldWallet);
|
||||
if (oldw)
|
||||
oldw.removeListener('txProposalEvent', _updateTxs);
|
||||
}
|
||||
|
||||
|
||||
var w = $rootScope.wallet;
|
||||
$rootScope.pendingTxCount = 0;
|
||||
w.on('txProposalEvent', function() { _updateTxs()});
|
||||
w.on('txProposalEvent', _updateTxs);
|
||||
_updateTxs();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// TODO duplicated on controller send. move to a service.
|
||||
$scope.notifyStatus = function(status) {
|
||||
if (status == copay.Wallet.TX_BROADCASTED)
|
||||
notification.success('Success', 'Transaction broadcasted!');
|
||||
else if (status == copay.Wallet.TX_PROPOSAL_SENT)
|
||||
notification.info('Success', 'Transaction proposal created');
|
||||
else if (status == copay.Wallet.TX_SIGNED)
|
||||
notification.success('Success', 'Transaction proposal was signed');
|
||||
else if (status == copay.Wallet.TX_SIGNED_AND_BROADCASTED)
|
||||
notification.success('Success', 'Transaction signed and broadcasted!');
|
||||
else
|
||||
notification.error('Error', 'Unknown error occured');
|
||||
};
|
||||
|
||||
|
||||
$scope.$on("$destroy", function() {
|
||||
var w = $rootScope.wallet;
|
||||
removeWatch();
|
||||
w.removeListener('txProposalEvent', function() {_updateTxs()} );
|
||||
w.removeListener('txProposalEvent', _updateTxs);
|
||||
});
|
||||
|
||||
$scope.setAlternativeAmount = function(w, tx, cb) {
|
||||
|
@ -69,7 +95,9 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
|
|||
}
|
||||
});
|
||||
$scope.txps = res.txs;
|
||||
console.log('[homeWallet.js:45]',$scope.txps); //TODO
|
||||
$timeout(function(){
|
||||
$scope.$digest();
|
||||
},1)
|
||||
}, 100);
|
||||
|
||||
|
||||
|
|
|
@ -245,15 +245,15 @@ angular.module('copayApp.services')
|
|||
$filter('translate')('You received a transaction proposal from') + ' ' + user);
|
||||
break;
|
||||
case 'signed':
|
||||
notification.info('[' + name + '] Transaction Signed',
|
||||
notification.success('[' + name + '] Transaction Signed',
|
||||
$filter('translate')('A transaction was signed by') + ' ' + user);
|
||||
break;
|
||||
case 'signedAndBroadcasted':
|
||||
notification.info('[' + name + '] Transaction Approved',
|
||||
notification.success('[' + name + '] Transaction Approved',
|
||||
$filter('translate')('A transaction was signed and broadcasted by') + ' ' + user);
|
||||
break;
|
||||
case 'rejected':
|
||||
notification.info('[' + name + '] Transaction Rejected',
|
||||
notification.warning('[' + name + '] Transaction Rejected',
|
||||
$filter('translate')('A transaction was rejected by') + ' ' + user);
|
||||
break;
|
||||
case 'corrupt':
|
||||
|
|
Loading…
Reference in New Issue