mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Fix #1333 Peer list doesn't update automatically
This commit is contained in:
parent
2e62ced811
commit
1f3a7bf44c
1 changed files with 18 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*!
|
/*!
|
||||||
* Deluge.details.PeersTab.js
|
* Deluge.details.PeersTab.js
|
||||||
*
|
*
|
||||||
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
@ -32,7 +32,9 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
function flagRenderer(value) {
|
function flagRenderer(value) {
|
||||||
if (!value) return '';
|
if (!value.replace(' ', '').replace(' ', '')){
|
||||||
|
return '';
|
||||||
|
}
|
||||||
return String.format('<img src="flag/{0}" />', value);
|
return String.format('<img src="flag/{0}" />', value);
|
||||||
}
|
}
|
||||||
function peerAddressRenderer(value, p, record) {
|
function peerAddressRenderer(value, p, record) {
|
||||||
|
@ -45,10 +47,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
|
Deluge.details.PeersTab = Ext.extend(Ext.grid.GridPanel, {
|
||||||
|
|
||||||
// fast way to figure out if we have a peer already.
|
// fast way to figure out if we have a peer already.
|
||||||
peers: {},
|
peers: {},
|
||||||
|
|
||||||
constructor: function(config) {
|
constructor: function(config) {
|
||||||
config = Ext.apply({
|
config = Ext.apply({
|
||||||
title: _('Peers'),
|
title: _('Peers'),
|
||||||
|
@ -95,26 +97,26 @@
|
||||||
sortable: true,
|
sortable: true,
|
||||||
renderer: fspeed,
|
renderer: fspeed,
|
||||||
dataIndex: 'up_speed'
|
dataIndex: 'up_speed'
|
||||||
}],
|
}],
|
||||||
stripeRows: true,
|
stripeRows: true,
|
||||||
deferredRender:false,
|
deferredRender:false,
|
||||||
autoScroll:true
|
autoScroll:true
|
||||||
}, config);
|
}, config);
|
||||||
Deluge.details.PeersTab.superclass.constructor.call(this, config);
|
Deluge.details.PeersTab.superclass.constructor.call(this, config);
|
||||||
},
|
},
|
||||||
|
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.getStore().removeAll();
|
this.getStore().removeAll();
|
||||||
this.peers = {};
|
this.peers = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function(torrentId) {
|
update: function(torrentId) {
|
||||||
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Peers, {
|
deluge.client.web.get_torrent_status(torrentId, Deluge.Keys.Peers, {
|
||||||
success: this.onRequestComplete,
|
success: this.onRequestComplete,
|
||||||
scope: this
|
scope: this
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onRequestComplete: function(torrent, options) {
|
onRequestComplete: function(torrent, options) {
|
||||||
if (!torrent) return;
|
if (!torrent) return;
|
||||||
|
|
||||||
|
@ -125,6 +127,14 @@
|
||||||
// Go through the peers updating and creating peer records
|
// Go through the peers updating and creating peer records
|
||||||
Ext.each(torrent.peers, function(peer) {
|
Ext.each(torrent.peers, function(peer) {
|
||||||
if (this.peers[peer.ip]) {
|
if (this.peers[peer.ip]) {
|
||||||
|
var record = store.getById(peer.ip);
|
||||||
|
record.beginEdit();
|
||||||
|
for (var k in peer) {
|
||||||
|
if (record.get(k) != peer[k]) {
|
||||||
|
record.set(k, peer[k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
record.endEdit();
|
||||||
} else {
|
} else {
|
||||||
this.peers[peer.ip] = 1;
|
this.peers[peer.ip] = 1;
|
||||||
newPeers.push(new Deluge.data.Peer(peer, peer.ip));
|
newPeers.push(new Deluge.data.Peer(peer, peer.ip));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue