fixes txproposal notifications

This commit is contained in:
Matias Alejo Garcia 2014-07-08 08:58:24 -03:00
commit 141e8bddd3
3 changed files with 22 additions and 38 deletions

View file

@ -41,44 +41,10 @@ angular.module('copayApp.controllers').controller('HeaderController',
}
});
$rootScope.unitName = config.unitName;
// Initialize alert notification (not show when init wallet)
$rootScope.txAlertCount = 0;
$rootScope.insightError = 0;
// Init socket handlers (with no wallet yet)
controllerUtils.setSocketHandlers();
$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) {
//var beep = new Audio('sound/transaction.mp3');
notification.funds('Received fund', currentAddr, receivedFund);
//beep.play();
}
}
});
$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);
}
});
$scope.isActive = function(item) {
if (item.link && item.link.replace('#', '') == $location.path()) {
return true;

View file

@ -67,9 +67,30 @@ angular.module('copayApp.services')
$rootScope.isCollapsed = true;
$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) {
//var beep = new Audio('sound/transaction.mp3');
notification.funds('Received fund', currentAddr, receivedFund);
//beep.play();
}
}
});
};

View file

@ -255,10 +255,7 @@ describe("Unit: Controllers", function() {
$httpBackend.verifyNoOutstandingRequest();
});
it('should have a txAlertCount', function() {
expect(scope.txAlertCount).equal(0);
$httpBackend.flush();
});
it('should hit github for version', function() {
$httpBackend.expectGET(GH);