improve behaviour when webserver goes away

This commit is contained in:
Damien Churchill 2010-05-03 02:14:51 +01:00
parent 619092aee0
commit 5b0f93ba72

View File

@ -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++;
},