From 1b82c3b52e46f359232761abe384e7536db197a6 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 27 Jun 2014 15:07:07 -0300 Subject: [PATCH 1/4] remove insight custom notification --- index.html | 10 ---------- js/controllers/header.js | 8 +++++--- js/services/controllerUtils.js | 7 ------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index a94954c57..df53bdefd 100644 --- a/index.html +++ b/index.html @@ -90,16 +90,6 @@ -
-
-
- Having troubles connecting to Insight server. Check - you settings and Internet connection.
- Reconnect Atempt #{{$root.insightError}} -
-
-
-
diff --git a/js/controllers/header.js b/js/controllers/header.js index 7d3d3d692..eeafd4517 100644 --- a/js/controllers/header.js +++ b/js/controllers/header.js @@ -49,14 +49,16 @@ angular.module('copayApp.controllers').controller('HeaderController', $rootScope.txAlertCount = 0; $rootScope.insightError = 0; + $rootScope.$watch('insightError', function(status) { if (status === -1) { - notification.success('Networking restored', 'Connection to insight restored'); - $rootScope.insightError = 0; + notification.success('Networking restored', 'Connection to Insight re-established'); + //$rootScope.insightError = 0; + } else { + notification.error('Networking problem', 'Connection to Insight lost, reconnecting (attempt number '+status+')'); } }); - // Init socket handlers (with no wallet yet) controllerUtils.setSocketHandlers(); diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index cbc293a1f..c823a2843 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -69,13 +69,6 @@ angular.module('copayApp.services') $rootScope.txAlertCount = 0; $rootScope.insightError = 0; $rootScope.isCollapsed = true; - $rootScope.$watch('insightError', function(status) { - if (status === -1) { - notification.success('Networking restored', 'Connection to Insight re-established'); - $rootScope.insightError = 0; - } - }); - $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); From 80376c16f806332a8383162fd97ae29e624db12a Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 27 Jun 2014 15:11:33 -0300 Subject: [PATCH 2/4] fix insight notification --- js/controllers/header.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/controllers/header.js b/js/controllers/header.js index eeafd4517..52e0bb352 100644 --- a/js/controllers/header.js +++ b/js/controllers/header.js @@ -54,7 +54,7 @@ angular.module('copayApp.controllers').controller('HeaderController', if (status === -1) { notification.success('Networking restored', 'Connection to Insight re-established'); //$rootScope.insightError = 0; - } else { + } else if (status !== 0) { notification.error('Networking problem', 'Connection to Insight lost, reconnecting (attempt number '+status+')'); } }); From f964467c01c958efe7923f9a7ae24284922aa101 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 27 Jun 2014 15:32:52 -0300 Subject: [PATCH 3/4] change version notifications to html5 --- index.html | 9 --------- js/controllers/header.js | 14 ++++++-------- js/services/notifications.js | 8 ++++++++ 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/index.html b/index.html index df53bdefd..4c460e1ca 100644 --- a/index.html +++ b/index.html @@ -81,15 +81,6 @@
-
-
-
- A newer version of Copay is now available ({{updateVersion.version}}), please update your wallet. - Check Copay.io for details. -
-
-
-
diff --git a/js/controllers/header.js b/js/controllers/header.js index 52e0bb352..803c3cec6 100644 --- a/js/controllers/header.js +++ b/js/controllers/header.js @@ -30,16 +30,14 @@ angular.module('copayApp.controllers').controller('HeaderController', }; var latestVersion = data[0].name.replace('v', '').split('.').map(toInt); var currentVersion = copay.version.split('.').map(toInt); + var title = 'Copay '+data[0].name+' available.'; + var content; if (currentVersion[0] < latestVersion[0]) { - $scope.updateVersion = { - class: 'error', - version: data[0].name - }; + content = 'It\'s important that you update your wallet at https://copay.io'; + notification.version(title, content, true); } else if (currentVersion[0] == latestVersion[0] && currentVersion[1] < latestVersion[1]) { - $scope.updateVersion = { - class: 'info', - version: data[0].name - }; + var content = 'Please update your wallet at https://copay.io'; + notification.version(title, content, false); } }); diff --git a/js/services/notifications.js b/js/services/notifications.js index e8f9bda2c..4c3c00e4b 100644 --- a/js/services/notifications.js +++ b/js/services/notifications.js @@ -16,6 +16,10 @@ factory('notification', ['$timeout', duration: 5000, enabled: true }, + version: { + duration: 60000, + enabled: true + }, warning: { duration: 5000, enabled: true @@ -135,6 +139,10 @@ factory('notification', ['$timeout', return this.awesomeNotify('funds', 'bitcoin', title, content, userData); }, + version: function(title, content, severe) { + return this.awesomeNotify('version', severe ? 'alert' : 'flag', title, content); + }, + error: function(title, content, userData) { return this.awesomeNotify('error', 'x', title, content, userData); }, From 87e1dddde97f11c3765573f9c731195f5e8f62b6 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 27 Jun 2014 15:42:08 -0300 Subject: [PATCH 4/4] fix version notification test --- test/unit/controllers/controllersSpec.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index fc6da0350..8525dc782 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -261,13 +261,14 @@ describe("Unit: Controllers", function() { $httpBackend.flush(); }); - it('should check version ', function() { + it('should check version ', inject(function($injector) { + notification = $injector.get('notification'); + var spy = sinon.spy(notification, 'version'); $httpBackend.expectGET(GH); scope.$apply(); $httpBackend.flush(); - expect(scope.updateVersion.class).equal('error'); - expect(scope.updateVersion.version).equal('v100.1.6'); - }); + spy.calledOnce.should.equal(true); + })); it('should check blockChainStatus', function() { $httpBackend.expectGET(GH);