From 7ff1ecb1ef5faa95eeaf58576588929c8f536d4c Mon Sep 17 00:00:00 2001 From: Duda Dornelles Date: Tue, 28 Oct 2014 17:57:53 +0100 Subject: Cleaning callbacks for mail sync progress bar in case of an error (which means, probably, that the server is not up). if we dont do this it will add fire a ridiculous amount of requests the next time will start the server --- .../app/js/mail_list/ui/mail_syncing_progress_bar.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'web-ui') diff --git a/web-ui/app/js/mail_list/ui/mail_syncing_progress_bar.js b/web-ui/app/js/mail_list/ui/mail_syncing_progress_bar.js index 8ab6457e..9cdcc5dc 100644 --- a/web-ui/app/js/mail_list/ui/mail_syncing_progress_bar.js +++ b/web-ui/app/js/mail_list/ui/mail_syncing_progress_bar.js @@ -46,13 +46,18 @@ define( }; this.doUpdate = function () { - $.getJSON('/sync_info', function (data) { - if (data.is_syncing) { - this.updateProgressBar(data.count); - } else { + $.getJSON('/sync_info') + .success(function (data) { + if (data.is_syncing) { + this.updateProgressBar(data.count); + } else { + this.resetProgressBar(); + } + }.bind(this)) + .error(function () { + clearInterval(this.attr.poolIntervalId); this.resetProgressBar(); - } - }.bind(this)); + }.bind(this)); }; this.checkForMailSyncing = function () { @@ -64,7 +69,7 @@ define( this.after('initialize', function () { this.checkForMailSyncing(); - setInterval(this.checkForMailSyncing.bind(this), 20000); + this.attr.poolIntervalId = setInterval(this.checkForMailSyncing.bind(this), 20000); }); } } -- cgit v1.2.3