stop an error in the peers tab if no data is returned

add the code to enforce the sidebar_show_zero option
This commit is contained in:
Damien Churchill 2009-06-02 12:34:54 +00:00
parent b54c73d466
commit b56bb9e2be
3 changed files with 26 additions and 2 deletions

View File

@ -135,6 +135,7 @@ Copyright:
},
onRequestComplete: function(torrent, options) {
if (!torrent) return;
var peers = new Array();
Ext.each(torrent.peers, function(peer) {
peers.push([peer.country, peer.ip, peer.client, peer.progress, peer.down_speed, peer.up_speed, peer.seed]);

View File

@ -33,7 +33,7 @@ Copyright:
*/
// These are just so gen_gettext.js will pick up the strings
// These are just so gen_gettext.py will pick up the strings
// _('State')
// _('Tracker Host')
@ -128,6 +128,11 @@ Copyright:
deferredRender: false,
autoScroll: true
});
if (Deluge.config['sidebar_show_zero'] == false) {
states = this.removeZero(states);
}
store.loadData(states);
this.add(panel);
@ -183,6 +188,19 @@ Copyright:
if (needsUpdate) Deluge.UI.update();
},
/**
* Remove the states with zero torrents in them.
*/
removeZero: function(states) {
var newStates = [];
Ext.each(states, function(state) {
if (state[1] > 0) {
newStates.push(state);
}
});
return newStates;
},
update: function(filters) {
for (var filter in filters) {
var states = filters[filter];
@ -197,11 +215,16 @@ Copyright:
Ext.each(Ext.keys(this.panels), function(filter) {
if (Ext.keys(filters).indexOf(filter) == -1) {
// We need to remove the panel
this.panels[filter]
}
});
},
updateFilter: function(filter, states) {
if (Deluge.config['sidebar_show_zero'] == false) {
states = this.removeZero(states);
}
this.panels[filter].store.loadData(states);
if (this.selected && this.selected.panel == this.panels[filter]) {
this.panels[filter].getSelectionModel().selectRow(this.selected.row);

File diff suppressed because one or more lines are too long