Merge pull request #3538 from cmgustavo/bug/alert-duplicated

Fixes alert popup duplicated
This commit is contained in:
Matias Alejo Garcia 2015-12-01 14:30:55 -03:00
commit 65ba330788

View file

@ -425,9 +425,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}; };
// This handles errors from BWS/index with are nomally // This handles errors from BWS/index with are nomally
// trigger from async events (like updates) // trigger from async events (like updates).
self.handleError = function(err) { // Debounce function avoids multiple popups
$log.warn('Client ERROR:', err); var _handleError = function(err) {
$log.warn('Client ERROR: ', err);
if (err.code === 'NOT_AUTHORIZED') { if (err.code === 'NOT_AUTHORIZED') {
self.notAuthorized = true; self.notAuthorized = true;
go.walletHome(); go.walletHome();
@ -440,6 +441,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.showErrorPopup(msg); self.showErrorPopup(msg);
} }
}; };
self.handleError = lodash.debounce(_handleError, 1000);
self.openWallet = function() { self.openWallet = function() {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
$timeout(function() { $timeout(function() {
@ -919,9 +923,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$log.warn('Showing err popup:' + msg); $log.warn('Showing err popup:' + msg);
self.showAlert = { self.showAlert = {
msg: msg, msg: msg,
close: function(err) { close: function() {
self.showAlert = null; self.showAlert = null;
if (cb) return cb(err); if (cb) return cb();
}, },
}; };
$timeout(function() { $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) { $rootScope.$on('Local/NeedsPassword', function(event, isSetup, cb) {
self.askPassword = { self.askPassword = {
isSetup: isSetup, isSetup: isSetup,