diff --git a/deluge/ui/web/js/deluge-all/ConnectionManager.js b/deluge/ui/web/js/deluge-all/ConnectionManager.js index 5261726fb..2e61e22a2 100644 --- a/deluge/ui/web/js/deluge-all/ConnectionManager.js +++ b/deluge/ui/web/js/deluge-all/ConnectionManager.js @@ -162,13 +162,23 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { }, update: function () { + this.updating = setTimeout(this.update, 2000); this.list.getStore().each(function (r) { deluge.client.web.get_host_status(r.id, { - success: this.onGetHostStatus, + success: this.onUpdate, scope: this, }); }, this); }, + onUpdate: function (host) { + if (!this.isVisible()) return; + this.onGetHostStatus(host); + + if (this.updating) { + clearTimeout(this.updating); + } + this.updating = setTimeout(this.update, 2000); + }, /** * Updates the buttons in the Connection Manager UI according to the @@ -312,7 +322,10 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { // private onHide: function () { - if (this.running) window.clearInterval(this.running); + if (this.updating) { + window.clearTimeout(this.updating); + this.updating = undefined; + } }, // private @@ -396,8 +409,8 @@ Deluge.ConnectionManager = Ext.extend(Ext.Window, { this.stopHostButton = bbar.items.get('cm-stop'); } this.loadHosts(); - if (this.running) return; - this.running = window.setInterval(this.update, 2000, this); + if (this.updating) return; + this.updating = window.setTimeout(this.update, 2000); }, // private diff --git a/deluge/ui/web/js/deluge-all/UI.js b/deluge/ui/web/js/deluge-all/UI.js index cc877d597..f7edc84b1 100644 --- a/deluge/ui/web/js/deluge-all/UI.js +++ b/deluge/ui/web/js/deluge-all/UI.js @@ -134,14 +134,24 @@ deluge.ui = { deluge.details.update(); }, - onConnectionError: function (error) {}, + onConnectionError: function (error) { + if (this.checking) { + clearTimeout(this.checking); + } + this.checking = setTimeout(this.checkConnection, 2000); + }, onConnectionSuccess: function (result) { + if (this.checking) { + clearTimeout(this.checking); + this.checking = undefined; + } + this.running = setTimeout(this.update, 2000); + this.update(); deluge.statusbar.setStatus({ iconCls: 'x-deluge-statusbar icon-ok', text: _('Connection restored'), }); - clearInterval(this.checking); if (!result) { deluge.connectionManager.show(); } @@ -159,9 +169,13 @@ deluge.ui = { deluge.statusbar.setStatus({ text: _('Lost connection to webserver'), }); - this.checking = setInterval(this.checkConnection, 2000); + this.checking = setTimeout(this.checkConnection, 2000); } this.errorCount++; + if (this.running) { + clearTimeout(this.running); + this.running = undefined; + } }, /** @@ -170,10 +184,15 @@ deluge.ui = { * Updates the various components in the interface. */ onUpdate: function (data) { + if (this.running) { + clearTimeout(this.running); + this.running = undefined; + } if (!data['connected']) { deluge.connectionManager.disconnect(true); return; } + this.running = setTimeout(this.update, 2000); if (deluge.config.show_session_speed) { document.title = @@ -201,7 +220,7 @@ deluge.ui = { */ onConnect: function () { if (!this.running) { - this.running = setInterval(this.update, 2000); + this.running = setTimeout(this.update, 2000); this.update(); } deluge.client.web.get_plugins({ @@ -280,8 +299,8 @@ deluge.ui = { */ stop: function () { if (this.running) { - clearInterval(this.running); - this.running = false; + clearTimeout(this.running); + this.running = undefined; deluge.torrents.getStore().removeAll(); } },