From e0396746f097b9faf9b3e178bd34d1a8eef8be6d Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Thu, 14 Aug 2014 10:23:37 -0300 Subject: [PATCH] Skip first networking notification error --- js/services/controllerUtils.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 646923bff..ef4c0b861 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -309,14 +309,22 @@ angular.module('copayApp.services') }); } + var connectionLost = false; $rootScope.$watch('insightError', function(status) { - if (status) { - if (status === -1) { - notification.success('Networking restored', 'Connection to Insight re-established'); - } else if (!isNaN(status)) { - notification.error('Networking problem', 'Connection to Insight lost, reconnecting (attempt number ' + status + ')'); - } + if (!status) return; + + // Reconnected + if (status === -1) { + if (!connectionLost) return; // Skip on first reconnect + connectionLost = false; + notification.success('Networking restored', 'Connection to Insight re-established'); + return; } + + // Retry + if (status == 1) return; // Skip the first try + connectionLost = true; + notification.error('Networking problem', 'Connection to Insight lost, reconnecting (attempt number ' + (status-1) + ')'); }); root._setCommError = function(e) { @@ -325,7 +333,6 @@ angular.module('copayApp.services') $rootScope.insightError++; }; - root._clearCommError = function(e) { if ($rootScope.insightError > 0) $rootScope.insightError = -1;