Merge pull request #444 from cmgustavo/feature/01-alert-txs

Feature/01 alert txs
This commit is contained in:
Mario Colque 2014-05-21 10:46:35 -03:00
commit 194ddc8079
6 changed files with 114 additions and 43 deletions

View file

@ -20,16 +20,34 @@ angular.module('copay.header').controller('HeaderController',
'icon': 'fi-archive',
'link': '#/backup'
}];
var beep = new Audio('sound/transaction.mp3');
// Initialize alert notification (not show when init wallet)
$rootScope.txAlertCount = 0;
$notification.enableHtml5Mode(); // for chrome: if support, enable it
$rootScope.$watch('txAlertCount', function(txAlertCount) {
if (txAlertCount && txAlertCount > 0) {
$notification.info('New Transaction', ($rootScope.txAlertCount == 1) ? 'You have a pending transaction proposal' : 'You have ' + $rootScope.txAlertCount + ' pending transaction proposals', txAlertCount);
}
});
$rootScope.$watch('receivedFund', function(receivedFund) {
if (receivedFund) {
var currentAddr;
for(var i=0;i<$rootScope.addrInfos.length;i++) {
var addrinfo = $rootScope.addrInfos[i];
if (addrinfo.address.toString() == receivedFund[1] && !addrinfo.isChange) {
currentAddr = addrinfo.address.toString();
break;
}
}
if (currentAddr) {
$notification.funds('Received fund', currentAddr, receivedFund);
beep.play();
}
}
});
$scope.isActive = function(item) {
if (item.link && item.link.replace('#','') == $location.path()) {
return true;
@ -46,6 +64,7 @@ angular.module('copay.header').controller('HeaderController',
var w = $rootScope.wallet;
w.connectToAll();
controllerUtils.updateBalance(function() {
$rootScope.$digest();
});
};