feat(p2p): show torrents number of other clients

This commit is contained in:
Alexey Kasyanchuk
2018-03-30 22:27:31 +03:00
parent 7952c283ef
commit 2ba49380f6
5 changed files with 43 additions and 14 deletions

View File

@ -87,21 +87,27 @@ window.isReady = () => {
}
window.peers = 0;
window.peersTorrents = 0;
class App extends Component {
componentDidMount() {
window.router()
appReady = true;
window.torrentSocket.on('peer', (numOfPeers) => {
window.peers = numOfPeers
window.torrentSocket.on('peer', (peer) => {
if(peer.size > window.peers)
window.peersTorrents = (window.peersTorrents || 0) + peer.torrents
else
window.peersTorrents = (window.peersTorrents || 0) - peer.torrents
window.peers = peer.size
this.forceUpdate()
})
window.torrentSocket.emit('peers', (numOfPeers) => {
if(numOfPeers > 0)
window.torrentSocket.emit('peers', (peers) => {
if(peers.size > 0 || window.peers == 1)
{
window.peers = numOfPeers
window.peers = peers.size
window.peersTorrents = peers.torrents
this.forceUpdate()
}
})

View File

@ -151,7 +151,7 @@ const Header = (props) => {
!window.currentWindow.isModal()
&&
<div className='fs0-85 pad0-75 column peers-status' style={{marginLeft: 'auto', marginTop: '-10px', color: window.peers > 0 ? '#42f445' : 'white'}}>
<div>rats peers: {window.peers} {window.peers > 0 ? ' (p2p rats search enabled)' : ' (p2p rats search not available at this moment)'}</div>
<div>rats peers: {window.peers} [{window.peersTorrents} torrents] {window.peers > 0 ? ' (p2p rats search enabled)' : ' (p2p rats search not available at this moment)'}</div>
{
window.p2pStatus == 0
&&