From 141e8bddd3a3d11868d523739c8d5dff8d27c245 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Tue, 8 Jul 2014 08:58:24 -0300 Subject: [PATCH] fixes txproposal notifications --- js/controllers/header.js | 34 ------------------------ js/services/controllerUtils.js | 21 +++++++++++++++ test/unit/controllers/controllersSpec.js | 5 +--- 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/js/controllers/header.js b/js/controllers/header.js index e3493d9ae..9a7acb166 100644 --- a/js/controllers/header.js +++ b/js/controllers/header.js @@ -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; diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 82386f91c..24bc8f04d 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -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(); + } + } + }); + }; diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index 3e396def7..e4a49e662 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -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);