From 09cc7869c04d70bcece5cee1bc1da796a42f62ee Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Thu, 26 Nov 2015 13:25:38 -0300 Subject: [PATCH] Fix duplicate alert popup --- src/js/controllers/index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index bd0c877f1..14f776634 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -425,9 +425,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r }; // This handles errors from BWS/index with are nomally - // trigger from async events (like updates) - self.handleError = function(err) { - $log.warn('Client ERROR:', err); + // trigger from async events (like updates). + // Debounce function avoids multiple popups + var _handleError = function(err) { + $log.warn('Client ERROR: ', err); if (err.code === 'NOT_AUTHORIZED') { self.notAuthorized = true; go.walletHome(); @@ -440,6 +441,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r self.showErrorPopup(msg); } }; + + self.handleError = lodash.debounce(_handleError, 1000); + self.openWallet = function() { var fc = profileService.focusedClient; $timeout(function() { @@ -919,9 +923,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r $log.warn('Showing err popup:' + msg); self.showAlert = { msg: msg, - close: function(err) { + close: function() { self.showAlert = null; - if (cb) return cb(err); + if (cb) return cb(); }, }; $timeout(function() { @@ -1343,10 +1347,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r ); }); - $rootScope.$on('Local/ShowAlert', function(event, msg, cb) { - self.showErrorPopup(msg, cb); - }); - $rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) { self.askPassword = { isSetup: isSetup,