use createDelegate and add the onHide method that stops updating the hosts grid

This commit is contained in:
Damien Churchill 2010-02-17 01:34:42 +00:00
commit 7bd5ba3cdb

View file

@ -161,10 +161,8 @@ Copyright:
initComponent: function() { initComponent: function() {
Ext.deluge.ConnectionManager.superclass.initComponent.call(this); Ext.deluge.ConnectionManager.superclass.initComponent.call(this);
this.on({ this.on('hide', this.onHide, this);
'hide': this.onHide, this.on('show', this.onShow, this);
'show': this.onShow
});
Deluge.Events.on('login', this.onLogin, this); Deluge.Events.on('login', this.onLogin, this);
Deluge.Events.on('logout', this.onLogout, this); Deluge.Events.on('logout', this.onLogout, this);
@ -243,6 +241,8 @@ Copyright:
] ]
}) })
}); });
this.update = this.update.createDelegate(this);
}, },
disconnect: function() { disconnect: function() {
@ -256,11 +256,11 @@ Copyright:
}); });
}, },
update: function(self) { update: function() {
self.grid.getStore().each(function(r) { this.grid.getStore().each(function(r) {
Deluge.Client.web.get_host_status(r.id, { Deluge.Client.web.get_host_status(r.id, {
success: self.onGetHostStatus, success: this.onGetHostStatus,
scope: self scope: this
}); });
}, this); }, this);
}, },
@ -337,7 +337,6 @@ Copyright:
}, this, {single: true}); }, this, {single: true});
} }
}); });
if (this.running) window.clearInterval(this.running);
this.hide(); this.hide();
} }
}, },
@ -360,6 +359,10 @@ Copyright:
if (this.grid.getSelectionModel().getSelected() == record) this.updateButtons(record); if (this.grid.getSelectionModel().getSelected() == record) this.updateButtons(record);
}, },
onHide: function() {
if (this.running) window.clearInterval(this.running);
},
onLogin: function() { onLogin: function() {
Deluge.Client.web.connected({ Deluge.Client.web.connected({
success: function(connected) { success: function(connected) {