diff --git a/deluge/ui/web/js/deluge-all/UI.js b/deluge/ui/web/js/deluge-all/UI.js index 15f788123..4f8efd823 100644 --- a/deluge/ui/web/js/deluge-all/UI.js +++ b/deluge/ui/web/js/deluge-all/UI.js @@ -98,10 +98,19 @@ deluge.ui = { }, this, {single: true}); this.update = this.update.createDelegate(this); + this.checkConnection = this.checkConnection.createDelegate(this); this.originalTitle = document.title; }, + checkConnection: function() { + deluge.client.web.connected({ + success: this.onConnectionSuccess, + failure: this.onConnectionError, + scope: this + }); + }, + update: function() { var filters = deluge.sidebar.getFilterStates(); deluge.client.web.update_ui(Deluge.Keys.Grid, filters, { @@ -112,6 +121,18 @@ deluge.ui = { deluge.details.update(); }, + onConnectionError: function(error) { + + }, + + onConnectionSuccess: function(result) { + deluge.statusbar.setStatus('Connection restored'); + clearInterval(this.checking); + if (!result) { + deluge.connectionManager.show(); + } + }, + onUpdateError: function(error) { if (this.errorCount == 2) { Ext.MessageBox.show({ @@ -120,6 +141,9 @@ deluge.ui = { buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.ERROR }); + deluge.events.fire('disconnect'); + deluge.statusbar.setStatus('Lost connection to webserver'); + this.checking = setInterval(this.checkConnection, 2000); } this.errorCount++; },