Merge pull request #1087 from yemel/fix/networking-notification

Skip first networking notification error
This commit is contained in:
Matias Alejo Garcia 2014-08-15 16:15:30 -04:00
commit b8fcc16a9d
1 changed files with 14 additions and 7 deletions

View File

@ -309,14 +309,22 @@ angular.module('copayApp.services')
}); });
} }
var connectionLost = false;
$rootScope.$watch('insightError', function(status) { $rootScope.$watch('insightError', function(status) {
if (status) { if (!status) return;
if (status === -1) {
notification.success('Networking restored', 'Connection to Insight re-established'); // Reconnected
} else if (!isNaN(status)) { if (status === -1) {
notification.error('Networking problem', 'Connection to Insight lost, reconnecting (attempt number ' + status + ')'); 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) { root._setCommError = function(e) {
@ -325,7 +333,6 @@ angular.module('copayApp.services')
$rootScope.insightError++; $rootScope.insightError++;
}; };
root._clearCommError = function(e) { root._clearCommError = function(e) {
if ($rootScope.insightError > 0) if ($rootScope.insightError > 0)
$rootScope.insightError = -1; $rootScope.insightError = -1;